/* =====================================================================
   IQ Test Web App  —  Stylesheet (responsif: mobile + desktop)
   ===================================================================== */

/* ---------- Variabel warna ---------- */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-soft: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
  --radius: 14px;
}

/* ---------- Reset ringan ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
}
.brand .logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 900;
  flex-shrink: 0;
}
.brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) {
  .brand { font-size: 1rem; gap: 0.4rem; }
  .brand .logo { width: 30px; height: 30px; font-size: 0.95rem; }
  .brand-name { font-size: 0.95rem; }
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}
.nav-links a { color: var(--text-soft); font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; }

/* ---------- Layout utama ---------- */
main { flex: 1 0 auto; }
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}
.container.wide { max-width: 1100px; }

/* ---------- Hero (home) ---------- */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--text);
}
.hero p {
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  color: var(--text-soft);
  max-width: 600px;
  margin: 0 auto 2rem;
}
.btn {
  display: inline-block;
  padding: 0.9rem 2rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.05rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-align: center;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; transform: translateY(-2px); }
.btn-secondary {
  background: var(--card);
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary-light); text-decoration: none; }
.btn-block { display: block; width: 100%; }

/* ---------- Kartu info ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2.5rem 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.card:hover { transform: translateY(-4px); }
.card .icon {
  width: 48px; height: 48px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}
.card h3 { margin-bottom: 0.4rem; font-size: 1.1rem; }
.card p { color: var(--text-soft); font-size: 0.95rem; }

/* ---------- Section ---------- */
.section { padding: 2rem 0; }
.section h2 {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 0.5rem;
}
.section .lead {
  text-align: center;
  color: var(--text-soft);
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

/* ---------- Halaman tes ---------- */
.test-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  position: sticky;
  top: 70px;
  z-index: 50;
}
.progress-wrap { flex: 1 1 200px; min-width: 200px; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 0.85rem; color: var(--text-soft); margin-bottom: 0.3rem;
}
.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  width: 0%;
  transition: width 0.3s ease;
}
.timer {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  background: var(--primary-light);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
}
.timer.warning { background: #fef3c7; color: #92400e; }
.timer.danger { background: #fee2e2; color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

/* ---------- Kartu soal ---------- */
.question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.q-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem; color: var(--text-soft); margin-bottom: 0.75rem;
}
.q-meta .cat {
  background: var(--primary-light); color: var(--primary);
  padding: 0.2rem 0.7rem; border-radius: 999px; font-weight: 600; font-size: 0.78rem;
}
.q-text {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 600;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}
.options { display: flex; flex-direction: column; gap: 0.7rem; }
.option {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1rem;
  background: #fff;
}
.option:hover { border-color: var(--primary); background: var(--primary-light); }
.option input { display: none; }
.option .badge {
  width: 28px; height: 28px; flex: 0 0 28px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; color: var(--text-soft);
}
.option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.option.selected .badge {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ---------- Navigasi tes ---------- */
.test-nav {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem;
}
.test-nav .btn { flex: 1; }

/* ---------- Halaman hasil ---------- */
.result-hero {
  text-align: center;
  padding: 2rem 1rem;
}
.score-circle {
  width: 180px; height: 180px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg, var(--border) 0deg);
  display: grid; place-items: center;
  position: relative;
}
.score-circle::before {
  content: ""; position: absolute; inset: 14px;
  background: var(--card); border-radius: 50%;
}
.score-circle .score-num {
  position: relative; z-index: 1;
  font-size: 3rem; font-weight: 900; color: var(--primary); line-height: 1;
}
.score-circle .score-label {
  position: relative; z-index: 1;
  font-size: 0.85rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 1px;
}
.result-class {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  margin: 0.5rem 0 1rem;
}
.result-class.superior { background: #dcfce7; color: #166534; }
.result-class.normal    { background: #dbeafe; color: #1e40af; }
.result-class.average   { background: #fef9c3; color: #854d0e; }
.result-class.low       { background: #fee2e2; color: #991b1b; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; text-align: center;
}
.stat .v { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.stat .k { font-size: 0.8rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Iklan ---------- */
.ad-slot {
  margin: 1.5rem auto;
  text-align: center;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 10px, #f8fafc 10px, #f8fafc 20px);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 0.8rem;
  overflow: hidden;
}
.ad-slot .ad-label { padding: 1rem; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 2rem 1rem 1.5rem;
  margin-top: auto;
}
.footer-grid {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
}
.footer-grid h4 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.footer-grid ul { list-style: none; }
.footer-grid li { margin-bottom: 0.4rem; }
.footer-grid a { color: var(--text-soft); font-size: 0.9rem; }
.footer-bottom {
  max-width: 1100px; margin: 1.5rem auto 0;
  padding-top: 1.5rem; border-top: 1px solid var(--border);
  text-align: center; color: var(--text-soft); font-size: 0.85rem;
}

/* ---------- Artikel / konten ---------- */
.prose { max-width: 720px; margin: 0 auto; }
.prose h1, .prose h2, .prose h3 { margin: 1.5rem 0 0.75rem; line-height: 1.3; }
.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.5rem; }
.prose p { margin-bottom: 1rem; color: var(--text); }
.prose ul, .prose ol { margin: 0 0 1rem 1.5rem; }
.prose li { margin-bottom: 0.4rem; }

/* Table styling inside prose (blog articles) */
.prose table,
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  overflow-x: auto;
  display: block;
}
.prose table thead,
article table thead { background: var(--brand, #4f46e5); color: #fff; }
.prose table th,
article table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border, #e2e8f0);
  white-space: nowrap;
}
.prose table td,
article table td {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border, #e2e8f0);
  vertical-align: top;
  color: var(--text, #1f2937);
}
.prose table tbody tr:nth-child(even),
article table tbody tr:nth-child(even) { background: #f8fafc; }
.prose table tbody tr:hover,
article table tbody tr:hover { background: #eef2ff; }

.page-header { text-align: center; margin-bottom: 1.5rem; }
.page-header h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.page-header p { color: var(--text-soft); }

/* ---------- FAQ ---------- */
.faq details {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 0.75rem;
}
.faq summary { font-weight: 600; cursor: pointer; font-size: 1.05rem; }
.faq details[open] summary { margin-bottom: 0.5rem; color: var(--primary); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 0.8rem 1.25rem;
  border-radius: 999px; font-size: 0.9rem; z-index: 999;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.toast.show { opacity: 1; }

/* ---------- Loader ---------- */
.loader { text-align: center; padding: 3rem 1rem; }
.spinner {
  width: 44px; height: 44px; border: 4px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  margin: 0 auto 1rem; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================
   RESPONSIVE — Tablet & Mobile
   =================================================================== */
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 1rem; gap: 0.5rem;
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.6rem 0.5rem; border-radius: 8px; }
  .nav-links a:hover { background: var(--primary-light); }

  .container { padding: 1.5rem 1rem; }
  .hero { padding: 2rem 1rem 1rem; }
  .test-header { position: static; }
  .test-nav { flex-direction: column-reverse; }
  .test-nav .btn { width: 100%; }
  .score-circle { width: 150px; height: 150px; }
  .score-circle .score-num { font-size: 2.4rem; }
}

@media (max-width: 480px) {
  .q-text { font-size: 1.05rem; }
  .option { padding: 0.8rem 0.85rem; }
  .btn { padding: 0.8rem 1.5rem; font-size: 1rem; }
}

/* ---------- Language switcher ---------- */
.lang-switch { position: relative; }
.lang-select {
  appearance: none; -webkit-appearance: none;
  background: var(--primary-light);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 2rem 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}
.lang-select:hover { background-color: #e0e7ff; }
.nav .lang-switch { margin-left: 0.5rem; }

/* ---------- Opsi gambar (SVG) ---------- */
/* Catatan: selector diperketat ke `> svg` (direct child) agar tidak
   menimpa SVG di dalam .vis-cell / .seq-cell yang punya styling sendiri.
   Sebelumnya `.q-visual svg` cocok untuk SEMUA SVG turunan, yang
   menerapkan padding 0.75rem & max-width 320px ke SVG sel matriks
   — memperkecil gambar matriks RPM. */
.q-visual {
  text-align: center;
  margin: 0 auto 1.25rem;
  max-width: 360px;
}
.q-visual > svg {
  width: 100%; height: auto; max-width: 320px;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 12px; padding: 0.75rem;
}
.q-visual .seq-row {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; flex-wrap: wrap;
}
.q-visual .seq-cell { width: 56px; height: 56px; }
.q-visual .seq-cell svg { width: 100%; height: 100%; padding: 4px; }
.q-visual .seq-q {
  width: 56px; height: 56px;
  border: 2px dashed var(--primary);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--primary); font-weight: 800; font-size: 1.4rem;
  background: var(--primary-light);
}
/* Opsi gambar (SVG) — perbesar agar RPM matrix & opsi terlihat jelas.
   Sebelumnya 110x110 — dinaikkan ke 130x130 untuk viewBox SVG 100. */
.option .opt-svg { width: 130px; height: 130px; flex: 0 0 130px; display: grid; place-items: center; }
.option .opt-svg svg { width: 100%; height: 100%; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 6px; }
.options.has-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  max-width: 560px;
  margin: 0 auto;
}
.options.has-images .option {
  justify-content: flex-start;
  align-items: center;
  padding: 0.5rem 0.6rem;
  gap: 0.55rem;
}
.options.has-images .option .opt-text { display: none; }

/* ---------- Matriks 3x3 RPM (Raven's Progressive Matrices) ---------- */
/* Catatan: ukuran .vis-cell dinaikkan dari 92px → 104px dan .vis-matrix
   max-width dari 320 → 360 untuk menampung viewBox SVG 100 (dari 60).
   Sebelumnya cell SVG viewBox 60 + padding .q-visual svg 0.75rem yang
   menimpa turunan → gambar sangat kecil & terpadat (terutama multi-shape
   di template expert level). */
.vis-matrix {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  justify-content: center;
  padding: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 360px;
  margin: 0 auto;
}
.vis-row {
  display: contents;
}
.vis-cell {
  width: 104px;
  height: 104px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px;
}
.vis-cell svg {
  width: 100%;
  height: 100%;
}
.vis-q {
  width: 104px;
  height: 104px;
  border: 2px dashed var(--primary);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.8rem;
  background: var(--primary-light, #eef2ff);
}
@media (max-width: 480px) {
  .q-visual { max-width: 300px; }
  .vis-matrix { max-width: 264px; gap: 4px; padding: 8px; }
  .vis-cell, .vis-q { width: 78px; height: 78px; }
  .vis-q { font-size: 1.4rem; }
  .option .opt-svg { width: 86px; height: 86px; flex: 0 0 86px; }
}

/* ---------- Aksesibilitas ---------- */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Google Translate widget (visible di nav, styling serasi tema)
   =====================================================================
   - Widget dipasang di #langSwitcher (pojok kanan atas nav).
   - Banner & credit Google Translate disembunyikan total.
   - Tampilan dropdown menyerupai lang-select native.
   ===================================================================== */

/* Sembunyikan banner Google Translate yang muncul di atas halaman */
.goog-te-banner-frame.skiptranslate,
.goog-te-gadget-icon,
.goog-logo-link,
.goog-logo,
.goog-te-balloon-frame,
iframe.goog-te-banner-frame,
iframe.skiptranslate { display: none !important; }
body { top: 0 !important; position: static !important; }
.goog-tooltip,
.goog-tooltip:hover,
.goog-text-highlight { background: transparent !important; box-shadow: none !important; }

/* Container di dalam #langSwitcher */
#langSwitcher .gt-switch {
  display: inline-flex;
  align-items: center;
  font-size: 0.9rem;
}

/* Sembunyikan label "Powered by Google" dan teks gadget bawaan */
.goog-te-gadget { font-size: 0 !important; color: transparent !important; }
.goog-te-gadget > span { display: none !important; }
.goog-te-gadget a.gt-rev { display: none !important; }
.goog-te-gadget img { display: none !important; }

/* Dropdown Google Translate — styling supaya serasi nav-select */
#google_translate_element .goog-te-combo,
.goog-te-combo {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23607a8d' d='M2 4l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-color: #fff;
  color: var(--text, #1f2937);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  outline: none !important;
  min-width: 120px;
}
#google_translate_element .goog-te-combo:hover,
.goog-te-combo:hover { border-color: var(--primary, #4f46e5); }
#google_translate_element .goog-te-combo:focus,
.goog-te-combo:focus { border-color: var(--primary, #4f46e5); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

/* Mobile: dropdown menyesuaikan layar kecil */
@media (max-width: 600px) {
  #google_translate_element .goog-te-combo,
  .goog-te-combo {
    min-width: 110px;
    padding: 5px 26px 5px 8px;
    font-size: 0.8rem;
  }
  #langSwitcher .gt-switch { font-size: 0.82rem; }
}

/* Tandai "Select Language" default agar muncul placeholder ramah */
#google_translate_element .goog-te-combo option:first-child {
  color: var(--text-soft, #6b7280);
}
