/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* ===== Theme Variables ===== */

/* Dark theme (default) */
:root {
  --bg-page: #121218;
  --bg-card: #1e1e2a;
  --bg-card-hover-shadow: rgba(0,0,0,.35);
  --bg-body-inner: #1e1e2a;
  --border-card: #2a2a3a;
  --border-header: #2a2a3a;
  --border-body: #2a2a3a;
  --border-table: #2a2a3a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-body: #c0c0d0;
  --text-heading: #f0f0ff;
  --link-color: #64b5f6;
  --accent: #F46C36;
  --accent-hover: #ff8a50;
  --danger-bg: #e53935;
  --danger-hover: #c62828;
  --toast-bg: #f0f0ff;
  --toast-color: #121218;
  --table-even: #252535;
  --dev-note-bg: #2a2040;
  --dev-note-color: #b39ddb;
  --download-card-bg: #1e1e2a;
  --chevron-color: #F46C36;
  --copy-icon-filter: invert(0.7);
}

/* Light theme */
[data-theme="light"] {
  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-hover-shadow: rgba(0,0,0,.09);
  --bg-body-inner: #ffffff;
  --border-card: #e8e8e8;
  --border-header: #e0e0e0;
  --border-body: #f0f0f0;
  --border-table: #e8e8e8;
  --text-primary: #1a1a2e;
  --text-secondary: #6c757d;
  --text-body: #444444;
  --text-heading: #16213e;
  --link-color: #1565C0;
  --accent: #F46C36;
  --accent-hover: #e55a20;
  --danger-bg: #e53935;
  --danger-hover: #c62828;
  --toast-bg: #1a1a2e;
  --toast-color: #ffffff;
  --table-even: #fafafa;
  --dev-note-bg: #f3f0ff;
  --dev-note-color: #673AB7;
  --download-card-bg: #ffffff;
  --chevron-color: #F46C36;
  --copy-icon-filter: none;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

/* ===== Container ===== */
.faq-container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 clamp(12px, 4vw, 32px);
}

/* ===== Top Bar (fixed) ===== */
.faq-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px clamp(10px, 3vw, 20px);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  gap: 8px;
  transition: background .3s;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  user-select: none;
}
.theme-toggle-track {
  width: 40px;
  height: 22px;
  background: #555;
  border-radius: 11px;
  position: relative;
  transition: background .3s;
}
[data-theme="light"] .theme-toggle-track {
  background: #ccc;
}
.theme-toggle-thumb {
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform .3s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(18px);
}

/* ===== Translate Widget ===== */
.translate-bar {
  padding: 3px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .3s, border-color .3s;
  overflow: hidden;
}

/* Override Google Translate widget styles to match theme */
.goog-te-gadget {
  font-size: 0 !important;
  color: transparent !important;
  line-height: 0 !important;
}
.goog-te-gadget .goog-te-combo {
  font-size: clamp(0.72rem, 1.8vw, 0.82rem) !important;
  font-family: inherit !important;
  padding: 5px 10px !important;
  border: 1px solid var(--border-card) !important;
  border-radius: 6px !important;
  background: var(--bg-page) !important;
  color: var(--text-primary) !important;
  outline: none !important;
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: menulist;
  transition: background .3s, color .3s, border-color .3s;
}
.goog-te-gadget .goog-te-combo:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(244,108,54,.18);
}
/* Hide branding text/logo */
.goog-te-gadget > span { display: none !important; }

/*
 * Google Translate injects a top notification bar (iframe + div)
 * when a page is translated. Hide it and prevent the body offset.
 */
.skiptranslate {
  display: none !important;
}
#google_translate_element .skiptranslate {
  display: block !important; /* keep our own widget visible */
}
.translate-bar .skiptranslate {
  display: block !important; /* keep our own widget visible */
}
#goog-gt-tt { display: none !important; }
body { top: 0 !important; position: static !important; }

/* ===== Donation Button ===== */
#donation-button {
  display: inline-block;
  padding: 6px 14px;
  background: var(--danger-bg);
  color: #fff;
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(0.65rem, 1.6vw, 0.8rem);
  letter-spacing: .5px;
  border-radius: 6px;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(229,57,53,.35);
  transition: background .2s, transform .15s;
  flex-shrink: 0;
}
#donation-button:hover { background: var(--danger-hover); transform: translateY(-1px); }
#donation-button:active { transform: translateY(0); }

/* ===== Header ===== */
.faq-page-header {
  padding: clamp(24px, 5vw, 48px) 0 clamp(12px, 3vw, 24px);
  padding-top: clamp(56px, 8vw, 72px); /* offset for fixed topbar */
  border-bottom: 2px solid var(--border-header);
  margin-bottom: clamp(16px, 3vw, 28px);
}

.faq-page-header h1 {
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

.faq-page-header .subtitle {
  font-size: clamp(0.8rem, 2.2vw, 1rem);
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 400;
}

/* ===== Banner ===== */
.faq-banner { margin-bottom: 20px; }
.faq-banner img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
}

/* ===== Accordion ===== */
.faq-accordion { display: flex; flex-direction: column; gap: 10px; padding-bottom: 100px; }

.faq-item {
  background: var(--bg-card);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid var(--border-card);
  overflow: hidden;
  transition: box-shadow .25s, background .3s, border-color .3s;
  scroll-margin-top: 110px; /* clear fixed topbar + sticky search */
}
.faq-item:hover { box-shadow: 0 3px 12px var(--bg-card-hover-shadow); }

/* Heading row */
.faq-heading {
  display: flex;
  align-items: center;
  padding: clamp(10px, 2.5vw, 16px) clamp(12px, 3vw, 20px);
  gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.faq-heading .copy-link {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  cursor: pointer;
  opacity: .55;
  transition: opacity .2s;
  filter: var(--copy-icon-filter);
}
.faq-heading .copy-link:hover { opacity: 1; }

.faq-heading h4 {
  flex: 1;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  margin: 0;
}

/* Chevron */
.faq-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  position: relative;
  transition: transform .3s ease;
}
.faq-chevron::before,
.faq-chevron::after {
  content: '';
  position: absolute;
  background: var(--chevron-color);
  border-radius: 1.5px;
  width: 10px;
  height: 2.5px;
  top: 50%;
}
.faq-chevron::before { left: 1px; transform: translateY(-50%) rotate(45deg); }
.faq-chevron::after  { right: 1px; transform: translateY(-50%) rotate(-45deg); }

.faq-item.open .faq-chevron { transform: rotate(180deg); }

/* Collapsible body */
.faq-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease;
}

.faq-body-inner {
  padding: 0 clamp(12px, 3vw, 20px) clamp(14px, 3vw, 22px);
  font-size: clamp(0.82rem, 2.2vw, 0.95rem);
  color: var(--text-body);
  line-height: 1.75;
  border-top: 1px solid var(--border-body);
  transition: color .3s;
}

.faq-body-inner a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.faq-body-inner a:hover { border-bottom-color: var(--link-color); }

/* ===== Content Images ===== */
.faq-body-inner img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 6px 0;
  display: inline-block;
}
.faq-body-inner img.copy-link { border-radius: 0; margin: 0; }

/* Small inline icons (audio/video) */
.faq-body-inner img[src="img/audio.png"],
.faq-body-inner img[src="img/video.png"] {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  border-radius: 0;
  margin: 0 2px;
}

/* ===== Tables inside FAQ ===== */
.faq-body-inner table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  margin: 10px 0;
  overflow-x: auto;
  display: block;
}
.faq-body-inner table tr { border-bottom: 1px solid var(--border-table); }
.faq-body-inner table td,
.faq-body-inner table th {
  padding: clamp(6px, 1.5vw, 12px);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.faq-body-inner table tr:nth-child(even) { background: var(--table-even); }

/* ===== Lists ===== */
.faq-body-inner ul { padding-left: 22px; margin: 8px 0; }
.faq-body-inner li { margin-bottom: 6px; }

/* ===== Download cards (FAQ 0) ===== */
.download-cards { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; }
.download-card {
  flex: 1 1 180px;
  max-width: 240px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 16px 20px;
  text-align: center;
  background: var(--download-card-bg);
  transition: background .3s;
}
.download-card h2 {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  margin-bottom: 10px;
  color: var(--text-heading);
}
.download-card img { max-width: 160px; height: auto; border-radius: 0; }

/* ===== Toast ===== */
.faq-toast {
  position: fixed;
  bottom: 2em;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg);
  color: var(--toast-color);
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0;
  z-index: 10000;
  white-space: nowrap;
  transition: opacity .3s, transform .3s;
}
.faq-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Developer integration note ===== */
.dev-note {
  color: var(--dev-note-color);
  padding: 12px 16px;
  background: var(--dev-note-bg);
  border-radius: 8px;
  text-align: center;
  margin-bottom: 14px;
  font-size: clamp(0.8rem, 2vw, 0.92rem);
  line-height: 1.6;
  transition: background .3s, color .3s;
}

/* ===== Responsive ===== */

/* Tiny watches & very narrow (< 300px) */
@media (max-width: 299px) {
  html { font-size: 13px; }
  .faq-topbar { padding: 4px 6px; gap: 4px; }
  .faq-heading { padding: 8px 8px; gap: 6px; }
  .faq-body-inner { padding: 0 8px 10px; }
  #donation-button { padding: 4px 8px; font-size: 0.55rem; }
  .theme-toggle-label { display: none; }
  .download-cards { flex-direction: column; }
  .download-card { max-width: 100%; }
}

/* Small phones (300-480px) */
@media (min-width: 300px) and (max-width: 480px) {
  .theme-toggle-label { display: none; }
  .download-cards { flex-direction: column; align-items: stretch; }
  .download-card { max-width: 100%; }
}

/* Large screens (> 1400px) */
@media (min-width: 1400px) {
  .faq-container { max-width: 1000px; }
}

/* Very large / TV (> 2000px) */
@media (min-width: 2000px) {
  html { font-size: 20px; }
  .faq-container { max-width: 1200px; }
}

/* Ultra-wide (> 3000px) */
@media (min-width: 3000px) {
  html { font-size: 26px; }
  .faq-container { max-width: 1600px; }
}

/* ===== Search ===== */
.faq-search-wrap {
  margin-bottom: 16px;
  position: sticky;
  top: 44px;
  z-index: 100;
  background: var(--bg-page);
  padding: 12px 0 8px;
  transition: background .3s;
}
.faq-search-wrap::before {
  content: '';
  position: absolute;
  left: clamp(14px, 3vw, 20px);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 1;
}
.faq-search {
  width: 100%;
  padding: clamp(10px, 2.5vw, 14px) clamp(14px, 3vw, 20px);
  padding-left: clamp(38px, 6vw, 48px);
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-family: inherit;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: border-color .2s, box-shadow .2s, background .3s, color .3s;
}
.faq-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244,108,54,.18), 0 2px 8px rgba(0,0,0,.06);
}
.faq-search::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}
.faq-item.hidden-by-search { display: none; }
.faq-no-results {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Print */
@media print {
  .faq-topbar, .faq-toast, .faq-banner, .faq-search-wrap { display: none; }
  .faq-body { max-height: none !important; }
  .faq-item { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}
