/* ============================================================
   Carta Irlandesa — design system
   Eye-comfort first: no pure white, no pure black, desaturated
   accents, pastel keyword highlights. Light + dark themes.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #FAF9F6;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #F1EFE9;
  --text: #2D2D2A;
  --text-muted: #6B6A64;
  --border: #E3E1D9;
  --primary: #2E7D5B;
  --primary-strong: #256549;
  --primary-soft: #E5F0EB;
  --error: #C0564B;
  --error-soft: #F7E6E4;
  --kw-question: #FFF3C4;
  --kw-question-text: #5C4D00;
  --kw-answer: #D9EAD9;
  --kw-answer-text: #1E4D33;
  --shadow: 0 1px 3px rgba(45, 45, 42, .08), 0 4px 16px rgba(45, 45, 42, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #1A1A1E;
  --bg-elevated: #232329;
  --bg-subtle: #2A2A31;
  --text: #E8E6E1;
  --text-muted: #A6A49D;
  --border: #37373F;
  --primary: #4CAF82;
  --primary-strong: #63C096;
  --primary-soft: #24352D;
  --error: #D97C72;
  --error-soft: #3A2A28;
  --kw-question: #4A4020;
  --kw-question-text: #F5E6A3;
  --kw-answer: #24402C;
  --kw-answer-text: #B5DFC0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

img { max-width: 100%; height: auto; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 3.5vw, 1.8rem); }
h3 { font-size: 1.15rem; }

.container { max-width: 1024px; margin: 0 auto; padding: 0 20px; }
/* Same width as the landing container so every page lines up. */
.container-narrow { max-width: 1024px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 27px; height: 27px; color: var(--primary); flex: 0 0 auto; }
.brand-word { font-size: 1.12rem; font-weight: 450; letter-spacing: -0.015em; white-space: nowrap; }
.brand-word b { font-weight: 750; color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 18px; }
.nav-links a { color: var(--text-muted); font-size: .95rem; }
.nav-links a.btn { color: #fff; }
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 50%;
  width: 34px; height: 34px; cursor: pointer; color: var(--text-muted); font-size: 1rem;
}

@media (max-width: 640px) {
  .nav-links a:not(.btn) { display: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: none; cursor: pointer; font-family: inherit;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 1rem;
  padding: 12px 24px; transition: background .15s, transform .1s;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: var(--bg-subtle); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: none; color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 8px 16px; font-size: .9rem; }
.btn-lg { padding: 15px 32px; font-size: 1.1rem; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- hero / landing ---------- */
.hero { padding: 64px 0 48px; text-align: center; }
.hero p.lead {
  font-size: 1.15rem; color: var(--text-muted); max-width: 620px;
  margin: 18px auto 30px;
}
.hero .cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-badge {
  display: inline-block; background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; padding: 5px 14px; font-size: .85rem; font-weight: 600;
  margin-bottom: 18px;
}

.section { padding: 48px 0; }
.section-alt { background: var(--bg-subtle); }
.section h2 { margin-bottom: 10px; }
.section .sub { color: var(--text-muted); margin-bottom: 28px; max-width: 640px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 8px; }
.card p { color: var(--text-muted); font-size: .95rem; }
.card .emoji { font-size: 1.8rem; margin-bottom: 10px; display: block; }

/* ---------- keyword highlights ---------- */
mark.kq {
  background: var(--kw-question); color: var(--kw-question-text);
  border-radius: 4px; padding: 1px 4px; font-weight: 600;
}
mark.ka {
  background: var(--kw-answer); color: var(--kw-answer-text);
  border-radius: 4px; padding: 1px 4px; font-weight: 600;
}

/* ---------- quiz ---------- */
.quiz-wrap { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; }
@media (max-width: 768px) {
  .quiz-wrap { padding-bottom: 110px; } /* room for the fixed next-button bar */
}
.quiz-topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; font-size: .9rem; color: var(--text-muted);
}
.quiz-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.quiz-timer.warning { color: var(--error); }
.quiz-exit {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; color: var(--text-muted);
  font-size: .85rem; margin-right: 8px; vertical-align: middle;
}
.quiz-exit:hover { color: var(--error); border-color: var(--error); }

.q-image {
  display: block; margin: 16px auto 0; width: 200px; max-width: 60%; height: auto;
}

.q-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 22px; box-shadow: var(--shadow);
}
.q-text-en { font-size: 1.15rem; font-weight: 600; line-height: 1.5; }
.q-text-pt { color: var(--text-muted); margin-top: 8px; font-size: .98rem; }

.options { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.option {
  display: block; width: 100%; text-align: left; font-family: inherit; font-size: 1rem;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; min-height: 48px; cursor: pointer; color: var(--text);
  transition: border-color .15s, background .15s;
  line-height: 1.45;
}
.option:hover { border-color: var(--primary); }
.option { display: flex; gap: 12px; align-items: flex-start; }
.opt-key {
  flex: 0 0 22px; height: 22px; margin-top: 2px;
  border: 1px solid var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; color: var(--text-muted);
}
.opt-body { flex: 1; }
.option .opt-pt { display: block; color: var(--text-muted); font-size: .88rem; margin-top: 2px; }

.quiz-hints { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.kbd-hint { text-align: center; margin-top: 14px; font-size: .85rem; }
@media (max-width: 768px) {
  .kbd-hint { display: none; }
  .opt-key { display: none; }
}
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.correct { border-color: var(--primary); background: var(--primary-soft); }
.option.wrong { border-color: var(--error); background: var(--error-soft); }
.option:disabled { cursor: default; }

.explanation {
  margin-top: 18px; background: var(--bg-subtle); border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 16px;
  font-size: .95rem;
}
.explanation .src { display: block; margin-top: 6px; color: var(--text-muted); font-size: .82rem; }

/* Desktop: the next button flows right after the question card.
   Mobile (<=768px): it becomes a fixed thumb-reach bar at the bottom. */
.quiz-footer { margin-top: 18px; }
.quiz-footer .inner { max-width: 680px; margin: 0 auto; display: flex; gap: 12px; align-items: center; justify-content: flex-end; }
.quiz-footer .progress-text { display: none; font-size: .9rem; color: var(--text-muted); white-space: nowrap; }
.quiz-footer .btn { min-width: 220px; }

@media (max-width: 768px) {
  .quiz-footer {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0;
    background: var(--bg-elevated); border-top: 1px solid var(--border);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  .quiz-footer .progress-text { display: block; }
  .quiz-footer .btn { flex: 1; min-width: 0; }
}

.progress-bar { height: 6px; background: var(--bg-subtle); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.progress-bar > div { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }

/* ---------- result ---------- */
.result-screen { text-align: center; padding: 40px 16px; }
.result-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 130px; height: 130px; border-radius: 50%; font-size: 1.6rem; font-weight: 800;
  margin-bottom: 18px; letter-spacing: .02em;
}
.result-badge.pass { background: var(--primary-soft); color: var(--primary); border: 3px solid var(--primary); }
.result-badge.fail { background: var(--error-soft); color: var(--error); border: 3px solid var(--error); }
.result-score { font-size: 2.4rem; font-weight: 800; margin: 6px 0; }
.result-cats { max-width: 460px; margin: 26px auto; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.result-cat-row { display: flex; align-items: center; gap: 12px; font-size: .92rem; }
.result-cat-row .name { flex: 0 0 46%; }
.result-cat-row .bar { flex: 1; height: 8px; background: var(--bg-subtle); border-radius: 4px; overflow: hidden; }
.result-cat-row .bar > div { height: 100%; background: var(--primary); }
.result-cat-row .pct { flex: 0 0 52px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 22px 0; }
.stat-tile {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.stat-tile .label { display: block; color: var(--text-muted); font-size: .85rem; }
.stat-tile .value { display: block; font-size: 2rem; font-weight: 800; margin-top: 4px; line-height: 1.2; }
.stat-tile .value .muted { font-size: 1rem; }
.stat-tile .hint { display: block; color: var(--text-muted); font-size: .82rem; margin-top: 4px; }

.menu-list { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.menu-item {
  display: flex; align-items: center; gap: 16px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
  color: var(--text); box-shadow: var(--shadow); cursor: pointer; font-family: inherit; font-size: 1rem;
  text-align: left; width: 100%;
}
.menu-item:hover { border-color: var(--primary); text-decoration: none; }
.menu-item .mi-emoji { font-size: 1.6rem; }
.menu-item .mi-body { flex: 1; }
.menu-item .mi-title { font-weight: 700; }
.menu-item .mi-desc { color: var(--text-muted); font-size: .88rem; }

/* ---------- question bank browser ---------- */
.browse-controls { display: flex; gap: 10px; margin: 18px 0 10px; flex-wrap: wrap; }
.browse-controls select, .browse-controls input {
  padding: 10px 12px; font-size: .95rem; font-family: inherit;
  background: var(--bg-elevated); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.browse-controls select { flex: 0 0 auto; }
.browse-controls input { flex: 1; min-width: 220px; }
.browse-controls input:focus, .browse-controls select:focus { outline: none; border-color: var(--primary); }
.browse-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.browse-list { display: flex; flex-direction: column; gap: 8px; }
.browse-item {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.browse-item.open { border-color: var(--primary); }
.browse-head {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  background: none; border: none; font-family: inherit; font-size: .95rem;
  color: var(--text); text-align: left; padding: 12px 14px; cursor: pointer;
}
.browse-id { flex: 0 0 auto; font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: 3px; }
.browse-q { flex: 1; line-height: 1.45; }
.browse-q-pt { display: block; color: var(--text-muted); font-size: .85rem; }
.browse-status { flex: 0 0 18px; font-weight: 700; }
.browse-status.ok { color: var(--primary); }
.browse-status.bad { color: var(--error); }
.browse-body { padding: 0 14px 14px; }
.browse-body .options { margin-top: 8px; }

/* ---------- flashcards ---------- */
.flashcard-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.flash-pair {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .95rem;
}
.flash-pair .arrow { color: var(--text-muted); }

/* ---------- forms ---------- */
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.form-field input, .form-field select {
  width: 100%; padding: 12px 14px; font-size: 1rem; font-family: inherit;
  background: var(--bg-elevated); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.form-field input:focus { outline: none; border-color: var(--primary); }
.form-error { color: var(--error); font-size: .9rem; margin: 8px 0; }
.form-ok { color: var(--primary); font-size: .9rem; margin: 8px 0; }

/* ---------- segmented control ---------- */
.segmented { display: inline-flex; background: var(--bg-subtle); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button {
  border: none; background: none; font-family: inherit; font-size: .88rem; color: var(--text-muted);
  padding: 7px 14px; border-radius: 6px; cursor: pointer;
}
.segmented button.active { background: var(--bg-elevated); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- guide/article pages ---------- */
.article { padding: 40px 0 64px; }
.article h1 { margin-bottom: 8px; }
.article .article-sub { color: var(--text-muted); margin-bottom: 30px; font-size: 1.05rem; }
.article h2 { margin: 34px 0 12px; }
.article h3 { margin: 24px 0 8px; }
.article p { margin-bottom: 14px; max-width: 70ch; }
.article ul, .article ol { margin: 0 0 14px 22px; max-width: 68ch; }
.article li { margin-bottom: 6px; }
.callout {
  background: var(--primary-soft); border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 16px; margin: 18px 0;
  font-size: .95rem;
}
.article table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: .93rem; }
.article th, .article td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.article th { background: var(--bg-subtle); }
.table-scroll { overflow-x: auto; }

/* ---------- pricing ---------- */
.price-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 30px 0; }
.price-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; text-align: center; box-shadow: var(--shadow); position: relative;
}
.price-card.featured { border-color: var(--primary); border-width: 2px; }
.price-card .plan-name { font-weight: 700; font-size: 1.05rem; }
.price-card .plan-price { font-size: 2.2rem; font-weight: 800; margin: 10px 0 2px; }
.price-card .plan-period { color: var(--text-muted); font-size: .88rem; margin-bottom: 16px; }
.price-card ul { list-style: none; text-align: left; margin: 18px 0; font-size: .93rem; }
.price-card li { padding: 5px 0 5px 26px; position: relative; }
.price-card li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 700; }
.tag-featured {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700;
  border-radius: 999px; padding: 3px 12px; white-space: nowrap;
}

/* ---------- footer (brand left + links right, divider, legal line) ---------- */
.site-footer {
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 56px 0 40px; margin-top: 72px; font-size: .88rem; color: var(--text-muted);
}
.footer-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 28px; flex-wrap: wrap;
}
.footer-tagline {
  font-family: Georgia, 'Times New Roman', serif; font-style: italic;
  color: var(--text-muted); font-size: .92rem; opacity: .85;
  margin: 0;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 10px 26px; padding-top: 4px; }
.footer-links a { color: var(--text-muted); font-size: .88rem; }
.footer-links a:hover { color: var(--primary); text-decoration: none; }
.footer-divider { border: none; border-top: 1px solid var(--border); margin: 40px 0 22px; }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px 24px; flex-wrap: wrap; font-size: .78rem; opacity: .75;
}
.footer-note { text-align: right; max-width: 58ch; }
@media (max-width: 640px) {
  .site-footer { padding: 40px 0 32px; }
  .footer-bottom { flex-direction: column; }
  .footer-note { text-align: left; }
}

/* Focus mode: during a quiz the page is just question + timer. */
body.quiz-focus .site-header,
body.quiz-focus .site-footer { display: none; }

/* ---------- utilities ---------- */
.text-center { text-align: center; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.muted { color: var(--text-muted); }
.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
