/* ==========================================================================
 COSYlanguages · English Grammar Manual Level C1 (interactive web edition)
 Cozy, friendly design system for teens and adults.
 ========================================================================== */

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

:root {
  --teal-900: var(--accent-900, #0c3f38);
  --teal-800: var(--accent-800, #0f5c50);
  --teal-700: var(--accent-700, #157c6c);
  --teal-600: var(--accent-600, #1c9483);
  --teal-500: var(--accent-500, #25a894);
  --teal-100: var(--accent-100, #e4f4f0);
  --teal-050: var(--accent-050, #f2faf8);

  --ink: #132321;
  --ink-soft: #3c5450;
  --paper: #faf8f3;
  --panel: #ffffff;
  --line: #e6e2d8;

  --role-subject: #3562e0;
  --role-verb: #1c8f56;
  --role-noun: #c9740a;
  --role-adj: #7c4fd6;

  --why-bg: #fdf3d6;
  --why-line: #c99a1f;
  --why-ink: #7a5b0c;

  --native-bg: #f1e9fb;
  --native-line: #8b5cf6;
  --native-ink: #5b3aa8;

  --mistake-bg: #fdf0f0;
  --mistake-line: #e55353;
  --mistake-ink: #9c1c1c;

  --mint-bg: #eaf6f1;
  --mint-line: #1c9483;
  --mint-ink: #0f5c50;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --shadow-card: 0 2px 4px rgba(19,35,33,.03), 0 10px 28px -8px rgba(19,35,33,.12);
  --shadow-hover: 0 4px 8px rgba(19,35,33,.05), 0 16px 36px -8px rgba(19,35,33,.20);

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

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); line-height: 1.65; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }

.topbar {
  background: var(--teal-900); color: #fff; padding: 12px 20px;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff;
}
.brand-mark {
  background: var(--teal-500); color: var(--teal-900); font-weight: 900;
  font-family: var(--font-display); width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; font-size: 15px;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.topbar-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar-nav a {
  color: var(--teal-100); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 6px; transition: background .15s;
}
.topbar-nav a:hover, .topbar-nav a.active { background: rgba(255,255,255,.12); color: #fff; }

.hero {
  background: linear-gradient(135deg, var(--teal-900), var(--teal-800));
  color: #fff; padding: 48px 20px 40px; text-align: center;
}
.hero-kicker {
  display: inline-block; background: rgba(255,255,255,.15); color: #fff;
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  padding: 4px 12px; border-radius: 99px; margin-bottom: 12px;
}
.hero h1 {
  font-family: var(--font-display); font-size: clamp(28px, 4.5vw, 42px);
  margin: 0 0 12px; font-weight: 900; line-height: 1.2;
}
.hero p.lead {
  max-width: 680px; margin: 0 auto; font-size: 17px; opacity: .92; line-height: 1.5;
}

.container { max-width: 1000px; margin: 0 auto; padding: 32px 20px 60px; }

.parts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px;
}
.part-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 24px; text-decoration: none; color: inherit; display: flex; flex-direction: column;
  box-shadow: var(--shadow-card); transition: transform .2s, box-shadow .2s; position: relative; overflow: hidden;
}
.part-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.part-card .stripe { position: absolute; top: 0; left: 0; right: 0; height: 5px; }
.part-card .pnum { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--teal-700); margin-bottom: 6px; }
.part-card h2 { font-family: var(--font-display); font-size: 19px; margin: 0 0 8px; color: var(--teal-900); }
.part-card p { font-size: 14px; color: var(--ink-soft); margin: 0 0 16px; flex-grow: 1; }
.part-card .topics-count { font-size: 13px; font-weight: 700; color: var(--teal-600); }

.page-head { margin-bottom: 28px; }
.page-head .eyebrow { font-size: 13px; font-weight: 800; color: var(--teal-600); text-transform: uppercase; letter-spacing: .5px; }
.page-head h1 { font-family: var(--font-display); font-size: 32px; margin: 4px 0 8px; color: var(--teal-900); }
.page-head .subtitle { font-size: 17px; color: var(--ink-soft); margin: 0; }
.page-head hr.rule { border: 0; height: 2px; background: var(--line); margin-top: 20px; }

.box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 20px; margin-bottom: 24px; box-shadow: var(--shadow-card);
}
.rule-box { border-left: 5px solid var(--teal-600); }
.outcome-banner { background: rgba(28,143,86,0.08); border-left: 4px solid var(--role-verb); padding: 12px 16px; margin-bottom: 20px; border-radius: 4px; }

.table-wrap { overflow-x: auto; margin: 16px 0; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14.5px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { background: var(--teal-050); color: var(--teal-900); font-weight: 700; }

.examples { background: var(--mint-bg); border-left: 4px solid var(--mint-line); padding: 16px; border-radius: var(--radius-s); margin-bottom: 24px; }
.examples .label { font-weight: 800; color: var(--mint-ink); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 8px; }
.examples ul { margin: 0; padding-left: 20px; color: var(--ink); }
.examples li { margin-bottom: 6px; }

.mistakes { background: var(--mistake-bg); border-left: 4px solid var(--mistake-line); padding: 16px; border-radius: var(--radius-s); margin-bottom: 24px; }
.mistakes .m-title { font-weight: 800; color: var(--mistake-ink); font-size: 14px; margin-bottom: 12px; }
.mflip { background: var(--panel, #fff); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; cursor: pointer; user-select: none; transition: background .15s; }
.mflip:hover { background: #fffdfd; }
.wrong-line { color: var(--mistake-ink); font-weight: 600; margin-bottom: 4px; }
.right-line { color: var(--role-verb); font-weight: 700; display: none; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.mflip.revealed .right-line { display: block; }
.mflip .hint { font-size: 12px; color: #888; font-style: italic; }
.mflip.revealed .hint { display: none; }

.checklist { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; margin-bottom: 24px; }
.checklist h3 { margin: 0 0 14px; font-size: 16px; font-family: var(--font-display); color: var(--teal-900); }
.check-item { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; cursor: pointer; font-size: 14.5px; }
.check-item input { margin-top: 3px; accent-color: var(--teal-600); width: 16px; height: 16px; }
.check-progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 14px; overflow: hidden; }
.check-progress-bar { height: 100%; background: var(--teal-500); width: 0%; transition: width .3s; }

.quiz-panel { background: var(--panel); border: 2px solid var(--teal-600); border-radius: var(--radius-m); padding: 24px; margin-bottom: 32px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.quiz-head h2 { margin: 0; font-family: var(--font-display); font-size: 18px; color: var(--teal-900); }
.quiz-score { font-weight: 800; color: var(--teal-700); font-size: 14px; }
.qitem { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.qitem:last-child { border-bottom: none; }
.qtext { font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.qopts { display: flex; flex-direction: column; gap: 8px; }
.qopt {
  background: var(--paper); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px;
  text-align: left; font-size: 14px; font-family: inherit; cursor: pointer; transition: all .15s;
}
.qopt:hover { background: var(--teal-050); border-color: var(--teal-500); }
.qopt.correct { background: #e6f7ef; border-color: var(--role-verb); color: #0e5a34; font-weight: 700; }
.qopt.wrong { background: var(--mistake-bg); border-color: var(--mistake-line); color: var(--mistake-ink); }
.qexplain { font-size: 13px; color: var(--ink-soft); margin-top: 8px; display: none; padding: 8px 12px; background: var(--paper); border-radius: 6px; }
.quiz-reset { background: var(--teal-700); color: #fff; border: 0; padding: 8px 16px; border-radius: 8px; font-weight: 700; cursor: pointer; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; }
.pager a {
  flex: 1; background: var(--panel); border: 1px solid var(--line); padding: 14px 18px; border-radius: var(--radius-m);
  text-decoration: none; color: inherit; display: flex; flex-direction: column; box-shadow: var(--shadow-card); transition: all .15s;
}
.pager a:hover { border-color: var(--teal-500); transform: translateY(-2px); }
.pager .dir { font-size: 12px; font-weight: 800; color: var(--teal-600); text-transform: uppercase; margin-bottom: 4px; }
.pager .ttl { font-weight: 700; font-size: 15px; color: var(--teal-900); }
.pager a.next { text-align: right; }

footer.site {
  background: var(--teal-900); color: var(--teal-100); padding: 24px 20px; text-align: center; font-size: 13.5px; margin-top: 60px;
}
footer.site a { color: #fff; text-decoration: underline; }




/* 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, #e4f4f0 14%, #151a16);
  --teal-050: color-mix(in srgb, #f2faf8 14%, #151a16);
  --ink: #e8f0e9;
  --ink-soft: #c8d8c9;
  --paper: #151a16;
  --panel: #1e241f;
  --line: color-mix(in srgb, #e6e2d8 42%, #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, #fdf0f0 16%, #151a16);
  --mistake-line: color-mix(in srgb, #e55353 42%, #151a16);
  --mistake-ink: color-mix(in srgb, #9c1c1c 45%, #ffffff);
  --mint-bg: color-mix(in srgb, #eaf6f1 16%, #151a16);
  --mint-line: color-mix(in srgb, #1c9483 42%, #151a16);
  --mint-ink: color-mix(in srgb, #0f5c50 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, #e4f4f0 14%, #151a16);
  --teal-050: color-mix(in srgb, #f2faf8 14%, #151a16);
  --ink: #e8f0e9;
  --ink-soft: #c8d8c9;
  --paper: #151a16;
  --panel: #1e241f;
  --line: color-mix(in srgb, #e6e2d8 42%, #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, #fdf0f0 16%, #151a16);
  --mistake-line: color-mix(in srgb, #e55353 42%, #151a16);
  --mistake-ink: color-mix(in srgb, #9c1c1c 45%, #ffffff);
  --mint-bg: color-mix(in srgb, #eaf6f1 16%, #151a16);
  --mint-line: color-mix(in srgb, #1c9483 42%, #151a16);
  --mint-ink: color-mix(in srgb, #0f5c50 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;
}
