/* ==========================================================================
   COSYlanguages — Breton Vocabulary & Grammar Manuals (Interactive Web Edition)
   Enhanced Cozy Design System & Cross-Device Responsive Layout
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800;900&family=Poppins:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* Breton brand ramp */
  --teal-900: var(--accent-900, #0f382c);
  --teal-800: var(--accent-800, #144f3e);
  --teal-700: var(--accent-700, #1c6b54);
  --teal-600: var(--accent-600, #24876b);
  --teal-500: var(--accent-500, #2ea684);
  --teal-100: var(--accent-100, #e3f5ef);
  --teal-050: var(--accent-050, #f1faf7);

  --ink: #13231e;
  --ink-soft: #3c544c;
  --paper: #fcfbf7;
  --panel: #ffffff;
  --line: #e3e0d5;

  /* Gender and role markers */
  --gour-color: #2f5fae;
  --gour-bg: #e9f0fb;
  --gwreg-color: #b81d64;
  --gwreg-bg: #fde8f2;
  --lies-color: #7c4fd6;
  --lies-bg: #f1e9fb;

  /* Grammar roles */
  --role-subject: #2f5fae;
  --role-verb: #1c8f56;
  --role-noun: #c9740a;
  --role-adj: #7c4fd6;
  --role-mutation: #b81d64;

  /* Callout families */
  --why-bg: #fdf3d6;   --why-line: #c99a1f;  --why-ink: #7a5b0c;
  --native-bg: #f1e9fb; --native-line: #8b5cf6; --native-ink: #5b3aa8;
  --mistake-bg: #fdecec; --mistake-line: #d64545; --mistake-ink: #9c1c1c;
  --connect-bg: #e8f4fd; --connect-line: #2f5fae; --connect-ink: #1b3b73;
  --mint-bg: #e3f5ef; --mint-line: #24876b; --mint-ink: #0f382c;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --shadow-card: 0 4px 16px -4px rgba(19,35,30,.08), 0 1px 3px rgba(19,35,30,.04);
  --shadow-hover: 0 12px 28px -8px rgba(19,35,30,.18);

  --font-display: 'Nunito', 'Poppins', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(circle at 10% 20%, rgba(227, 245, 239, 0.4) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(253, 243, 214, 0.3) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--teal-700); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--teal-500); outline-offset: 3px; }

/* Accessible Touch Target Utility */
button, .btn, .qopt, .topic-card, .check-item, .pager a {
  min-height: 44px;
  touch-action: manipulation;
}

.container { max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* Topbar Header */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(15, 56, 44, 0.95);
  backdrop-filter: blur(10px);
  color: #eafaf5; border-bottom: 1px solid rgba(255,255,255,.1);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #eafaf5; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--panel, #fff); color: var(--teal-900);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 16px;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: 0.2px; }
.topbar-nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.topbar-nav a {
  color: #cdece4; text-decoration: none; font-size: 13px; font-weight: 700;
  padding: 8px 12px; border-radius: 99px; transition: background .15s, color .15s;
  min-height: 38px; display: inline-flex; align-items: center;
}
.topbar-nav a:hover, .topbar-nav a.active { background: rgba(255,255,255,.18); color: #fff; }

/* Page Header & Eyebrows */
.page-head { padding: 32px 0 20px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--teal-800);
  background: var(--teal-100); padding: 6px 14px; border-radius: 99px; margin-bottom: 12px;
}
.page-head h1 {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(28px, 5vw, 42px);
  margin: 0 0 8px; color: var(--ink); letter-spacing: -.01em; line-height: 1.2;
}
.page-head .subtitle { font-style: italic; color: var(--ink-soft); font-size: 17px; margin: 0; }
.rule { border: none; border-top: 2px solid var(--line); margin: 20px 0 0; }

/* Gender & Role Badges */
.badge-gender {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 800; font-size: 11px;
  padding: 3px 9px; border-radius: 6px; letter-spacing: .03em;
}
.badge-gender.gour { background: var(--gour-bg); color: var(--gour-color); border: 1px solid #bcdaf5; }
.badge-gender.gwreg { background: var(--gwreg-bg); color: var(--gwreg-color); border: 1px solid #f8c2dc; }
.badge-gender.lies { background: var(--lies-bg); color: var(--lies-color); border: 1px solid #e1d2fa; }

.ipa { font-family: var(--font-mono); color: var(--ink-soft); font-size: 13px; }

/* Callout Boxes */
.box { border-radius: var(--radius-m); padding: 20px 22px; margin: 20px 0; border: 1px solid transparent; box-shadow: var(--shadow-card); }
.box h3 { margin: 0 0 8px; font-family: var(--font-display); font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.box p { margin: 0; font-size: 15px; }
.box.why { background: var(--why-bg); border-color: #eddca0; color: var(--why-ink); }
.box.native { background: var(--native-bg); border-color: #e2d4fb; color: var(--native-ink); }
.box.mint { background: var(--mint-bg); border-color: #c9e9de; color: var(--mint-ink); }
.box.connect { background: var(--connect-bg); border-color: #bcd6f5; color: var(--connect-ink); }

/* Audio TTS Button */
.btn-tts {
  background: var(--teal-100); color: var(--teal-800); border: 1px solid var(--teal-500);
  border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; transition: background 0.15s, transform 0.15s;
}
.btn-tts:hover { background: var(--teal-500); color: #fff; transform: scale(1.05); }

/* Vocab Grid & Cards */
.vocab-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin: 24px 0; }
.vocab-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 18px; box-shadow: var(--shadow-card); text-align: center; position: relative;
  transition: transform .2s, box-shadow .2s;
}
.vocab-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.vocab-card .word { font-family: var(--font-display); font-weight: 900; font-size: 21px; color: var(--ink); }
.vocab-card .meta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Grammar Blocks */
.block-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; margin: 24px 0; }
.gblock {
  border-radius: var(--radius-s); padding: 12px 20px; text-align: center; color: #fff; min-width: 100px;
  box-shadow: 0 4px 12px -4px rgba(0,0,0,.2);
}
.gblock .k { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; opacity: .9; text-transform: uppercase; }
.gblock .v { display: block; font-family: var(--font-display); font-weight: 800; font-size: 18px; margin-top: 2px; }
.gblock.subject { background: var(--role-subject); }
.gblock.verb { background: var(--role-verb); }
.gblock.noun { background: var(--role-noun); }
.gblock.adj { background: var(--role-adj); }
.gblock.mutation { background: var(--role-mutation); }

/* Examples Box */
.examples { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px 22px; margin: 20px 0; box-shadow: var(--shadow-card); }
.examples .label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-700); font-weight: 800; margin-bottom: 10px; display: block; }
.examples ul { margin: 0; padding-left: 20px; }
.examples li { margin: 8px 0; font-size: 15.5px; }

/* Mistake Cards */
.mistakes { margin: 24px 0; }
.mistakes .m-title { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--mistake-ink); display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.mflip {
  background: var(--mistake-bg); border: 1px solid #f4c6c6; border-radius: var(--radius-m);
  padding: 16px; margin-bottom: 12px; cursor: pointer; user-select: none; transition: background .15s, transform 0.15s;
}
.mflip:hover { background: #fbe0e0; transform: translateY(-1px); }
.mflip .wrong-line { display: flex; gap: 8px; align-items: flex-start; font-size: 15.5px; }
.mflip .wrong-line .x { color: var(--mistake-line); font-weight: 900; }
.mflip .wrong-text { text-decoration: line-through; color: #8a3b3b; }
.mflip .right-line { display: none; gap: 8px; align-items: flex-start; font-size: 15.5px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed #f0b8b8; }
.mflip .right-line .c { color: #1c8f56; font-weight: 900; }
.mflip.flipped .right-line { display: flex; }
.mflip .hint { font-family: var(--font-mono); font-size: 11px; color: #b56060; margin-top: 4px; display: block; }
.mflip.flipped .hint { display: none; }

/* Checklist */
.checklist { background: var(--mint-bg); border: 1px solid #c9e9de; border-radius: var(--radius-m); padding: 20px 22px; margin: 26px 0; box-shadow: var(--shadow-card); }
.checklist h3 { margin: 0 0 12px; font-family: var(--font-display); font-size: 15px; font-weight: 800; color: var(--mint-ink); }
.check-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 15.5px; cursor: pointer; border-bottom: 1px solid rgba(36,135,107,.12); }
.check-item:last-child { border-bottom: none; }
.check-item input { width: 20px; height: 20px; accent-color: var(--teal-700); cursor: pointer; }
.check-item.done span { text-decoration: line-through; color: var(--ink-soft); }
.check-progress { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--mint-ink); margin-top: 12px; }

/* Quizzes */
.quiz-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 26px; margin: 34px 0; box-shadow: var(--shadow-card); }
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.quiz-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; font-weight: 800; }
.quiz-score { font-family: var(--font-mono); font-size: 13px; background: var(--teal-100); color: var(--teal-800); padding: 6px 14px; border-radius: 99px; font-weight: 800; }
.qitem { border-top: 1px solid var(--line); padding: 20px 0; }
.qitem:first-of-type { border-top: none; padding-top: 14px; }
.qitem .qtext { font-weight: 800; font-size: 16.5px; margin-bottom: 14px; }
.qopts { display: flex; flex-direction: column; gap: 10px; }
.qopt {
  text-align: left; border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--radius-s);
  padding: 12px 16px; font-size: 15.5px; cursor: pointer; font-family: var(--font-body); color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s;
}
.qopt:hover { border-color: var(--teal-500); transform: translateX(2px); }
.qopt.correct { border-color: #1c8f56; background: #e6f6ec; font-weight: 800; }
.qopt.incorrect { border-color: var(--mistake-line); background: var(--mistake-bg); }
.qexplain { display: none; margin-top: 12px; font-size: 14.5px; background: var(--teal-050); border-left: 4px solid var(--teal-600); padding: 12px 16px; border-radius: 8px; }
.qexplain.show { display: block; }

/* Pager Navigation */
.pager { display: flex; justify-content: space-between; gap: 16px; margin: 40px 0 10px; flex-wrap: wrap; }
.pager a {
  flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 20px;
  text-decoration: none; color: var(--ink); background: var(--panel); box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.pager a:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--teal-500); }
.pager a .dir { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--teal-700); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.pager a .ttl { display: block; font-family: var(--font-display); font-weight: 800; font-size: 16px; margin-top: 4px; }
.pager a.next { text-align: right; }

footer.site { background: var(--ink); color: #c9d8d4; padding: 36px 0; margin-top: 60px; font-size: 14px; }
footer.site a { color: #eafaf5; text-decoration: underline; }
footer.site .container { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* Hero Section & Interactive Builder */
.hero { background: linear-gradient(135deg, var(--teal-900), #1c6b54); color: #eafaf5; padding: 56px 0 50px; position: relative; overflow: hidden; }
.hero .container { position: relative; z-index: 2; }
.hero-kicker { font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #8fd6c4; font-weight: 700; }
.hero h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(32px, 5.5vw, 52px); margin: 12px 0; letter-spacing: -.01em; line-height: 1.15; }
.hero p.lead { max-width: 580px; color: #cdeee5; font-size: 17.5px; }

.hero-builder { margin-top: 32px; background: rgba(0, 0, 0, 0.2); padding: 22px; border-radius: var(--radius-m); border: 1px solid rgba(255, 255, 255, 0.15); }
.hero-builder .instruction { font-family: var(--font-mono); font-size: 12px; color: #8fd6c4; margin-bottom: 12px; font-weight: 700; }
.pool { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.pool button {
  font-family: var(--font-display); font-weight: 800; font-size: 14.5px; border-radius: 10px; border: none;
  padding: 10px 18px; cursor: pointer; color: #fff; transition: transform 0.15s, opacity 0.15s;
}
.pool button:hover { transform: scale(1.04); opacity: 1; }
.slot-row { display: flex; gap: 12px; min-height: 52px; align-items: center; flex-wrap: wrap; }
.slot {
  flex: 1; min-width: 110px; height: 46px; border: 2px dashed rgba(255,255,255,.4); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11.5px; color: rgba(255,255,255,.65);
}
.slot.filled { border-style: solid; border-color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 15.5px; color: #fff; background: rgba(255,255,255,0.15); }
.sentence-out { margin-top: 16px; font-family: var(--font-display); font-size: 21px; min-height: 32px; font-style: italic; color: #fff; font-weight: 700; }

/* Filter Pills & Topics Grid */
.filter-pills { display: flex; gap: 8px; margin: 20px 0; flex-wrap: wrap; }
.filter-pill {
  background: var(--panel); border: 1.5px solid var(--line); color: var(--ink-soft);
  padding: 8px 16px; border-radius: 99px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-pill:hover, .filter-pill.active { background: var(--teal-700); color: #fff; border-color: var(--teal-700); }

.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin: 24px 0; }
.topic-card {
  display: flex; flex-direction: column; justify-content: space-between;
  text-decoration: none; color: var(--ink); background: var(--panel); border-radius: var(--radius-m);
  padding: 22px; border: 1px solid var(--line); box-shadow: var(--shadow-card); position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--teal-500); }
.topic-card .tnum { font-family: var(--font-mono); font-size: 11.5px; color: var(--teal-700); font-weight: 800; }
.topic-card h2 { font-family: var(--font-display); font-size: 19px; margin: 6px 0 8px; font-weight: 800; line-height: 1.3; }
.topic-card p { margin: 0; color: var(--ink-soft); font-size: 14px; }

/* Cross-Device Responsive Rules */
@media (max-width: 768px) {
  .topbar-nav { display: none; }
  .hero { padding: 40px 0 36px; }
  .hero-builder { padding: 16px; }
  .slot-row { flex-direction: column; }
  .slot { width: 100%; }
  .vocab-cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .topics-grid { grid-template-columns: 1fr; }
  .pager { flex-direction: column; }
  .pager a.next { text-align: left; }
}

@media (max-width: 480px) {
  .vocab-cards-grid { grid-template-columns: 1fr; }
  .box { padding: 16px; }
  .quiz-panel { padding: 18px; }
}

/* Print Styles */
@media print {
  .topbar, .pager, .filter-pills, .btn-tts { display: none !important; }
  .box, .card, .mflip, .examples, .quiz-panel { background: none !important; box-shadow: none !important; border: 1px solid #ccc !important; }
  h1 { page-break-before: always; break-before: page; }
  .qexplain { display: block !important; }
  .mflip .right-line { display: flex !important; }
}

/* Per-word example sentence on vocabulary cards */
.vocab-card .example {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 8px;
  line-height: 1.35;
  font-style: italic;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}




/* Dark theme: the palette above is light-only, so the same role
   tokens are re-derived over a dark base when the OS prefers dark
   or an explicit theme is set. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --teal-100: color-mix(in srgb, #e3f5ef 14%, #151a16);
  --teal-050: color-mix(in srgb, #f1faf7 14%, #151a16);
  --ink: #e8f0e9;
  --ink-soft: #c8d8c9;
  --paper: #151a16;
  --panel: #1e241f;
  --line: color-mix(in srgb, #e3e0d5 42%, #151a16);
  --gour-bg: color-mix(in srgb, #e9f0fb 16%, #151a16);
  --gwreg-bg: color-mix(in srgb, #fde8f2 16%, #151a16);
  --lies-bg: color-mix(in srgb, #f1e9fb 16%, #151a16);
  --why-bg: color-mix(in srgb, #fdf3d6 16%, #151a16);
  --why-line: color-mix(in srgb, #c99a1f 42%, #151a16);
  --why-ink: color-mix(in srgb, #7a5b0c 45%, #ffffff);
  --native-bg: color-mix(in srgb, #f1e9fb 16%, #151a16);
  --native-line: color-mix(in srgb, #8b5cf6 42%, #151a16);
  --native-ink: color-mix(in srgb, #5b3aa8 45%, #ffffff);
  --mistake-bg: color-mix(in srgb, #fdecec 16%, #151a16);
  --mistake-line: color-mix(in srgb, #d64545 42%, #151a16);
  --mistake-ink: color-mix(in srgb, #9c1c1c 45%, #ffffff);
  --connect-bg: color-mix(in srgb, #e8f4fd 16%, #151a16);
  --connect-line: color-mix(in srgb, #2f5fae 42%, #151a16);
  --connect-ink: color-mix(in srgb, #1b3b73 45%, #ffffff);
  --mint-bg: color-mix(in srgb, #e3f5ef 16%, #151a16);
  --mint-line: color-mix(in srgb, #24876b 42%, #151a16);
  --mint-ink: color-mix(in srgb, #0f382c 45%, #ffffff);
  /* table headers paint --ink as a fill, which turns light in dark mode */
  --thead-fill: color-mix(in srgb, var(--ink) 16%, #151a16);
  }
  :root:not([data-theme="light"]) thead th {
    background: var(--thead-fill) !important; color: var(--ink) !important;
  }
}
html[data-theme="dark"], body.theme-dark {
  --teal-100: color-mix(in srgb, #e3f5ef 14%, #151a16);
  --teal-050: color-mix(in srgb, #f1faf7 14%, #151a16);
  --ink: #e8f0e9;
  --ink-soft: #c8d8c9;
  --paper: #151a16;
  --panel: #1e241f;
  --line: color-mix(in srgb, #e3e0d5 42%, #151a16);
  --gour-bg: color-mix(in srgb, #e9f0fb 16%, #151a16);
  --gwreg-bg: color-mix(in srgb, #fde8f2 16%, #151a16);
  --lies-bg: color-mix(in srgb, #f1e9fb 16%, #151a16);
  --why-bg: color-mix(in srgb, #fdf3d6 16%, #151a16);
  --why-line: color-mix(in srgb, #c99a1f 42%, #151a16);
  --why-ink: color-mix(in srgb, #7a5b0c 45%, #ffffff);
  --native-bg: color-mix(in srgb, #f1e9fb 16%, #151a16);
  --native-line: color-mix(in srgb, #8b5cf6 42%, #151a16);
  --native-ink: color-mix(in srgb, #5b3aa8 45%, #ffffff);
  --mistake-bg: color-mix(in srgb, #fdecec 16%, #151a16);
  --mistake-line: color-mix(in srgb, #d64545 42%, #151a16);
  --mistake-ink: color-mix(in srgb, #9c1c1c 45%, #ffffff);
  --connect-bg: color-mix(in srgb, #e8f4fd 16%, #151a16);
  --connect-line: color-mix(in srgb, #2f5fae 42%, #151a16);
  --connect-ink: color-mix(in srgb, #1b3b73 45%, #ffffff);
  --mint-bg: color-mix(in srgb, #e3f5ef 16%, #151a16);
  --mint-line: color-mix(in srgb, #24876b 42%, #151a16);
  --mint-ink: color-mix(in srgb, #0f382c 45%, #ffffff);
  /* table headers paint --ink as a fill, which turns light in dark mode */
  --thead-fill: color-mix(in srgb, var(--ink) 16%, #151a16);
}
html[data-theme="dark"] thead th, body.theme-dark thead th {
  background: var(--thead-fill) !important; color: var(--ink) !important;
}
