/* Detto Fatto! — grammar tutorials
   Design follows the "Reimagining Intermediate Italian" deck. */

@font-face { font-family: "Gilda Display"; font-weight: 400; font-display: swap;
  src: url("fonts/gilda-display-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Gilda Display"; font-weight: 400; font-display: swap;
  src: url("fonts/gilda-display-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Lexend"; font-weight: 300; font-display: swap; src: url("fonts/lexend-latin-300-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212; }
@font-face { font-family: "Lexend"; font-weight: 400; font-display: swap; src: url("fonts/lexend-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212; }
@font-face { font-family: "Lexend"; font-weight: 600; font-display: swap; src: url("fonts/lexend-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212; }
@font-face { font-family: "Lexend"; font-weight: 300; font-display: swap; src: url("fonts/lexend-latin-ext-300-normal.woff2") format("woff2"); unicode-range: U+0100-02AF, U+1E00-1EFF; }
@font-face { font-family: "Lexend"; font-weight: 400; font-display: swap; src: url("fonts/lexend-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02AF, U+1E00-1EFF; }
@font-face { font-family: "Lexend"; font-weight: 600; font-display: swap; src: url("fonts/lexend-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02AF, U+1E00-1EFF; }

:root {
  --bg: #f1f1f1;
  --card: #ffffff;
  --ink: #664b38;        /* brown text */
  --ink-dark: #4e3829;
  --muted: #74675a;
  --accent: #ae0439;     /* burgundy */
  --beige: #e7dfd6;
  --line: #8a7563;
  --arc: #dcdad7;
  --radius: 10px;
  --shadow: 0 2px 0 rgba(102, 75, 56, .14), 0 1px 3px rgba(0, 0, 0, .05);
  --serif: "Gilda Display", "Cormorant Garamond", Georgia, serif;
  --sans: "Lexend", "Segoe UI", system-ui, sans-serif;
  --max: 1080px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-weight: 300; font-size: 1.0625rem; line-height: 1.55;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink-dark); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Text roles used inside lessons */
b  { color: var(--accent); font-weight: 600; }      /* the grammar point */
strong { color: var(--ink-dark); font-weight: 600; } /* plain emphasis */
.en { display: block; font-style: italic; color: var(--muted); font-size: .92em; margin-top: .15rem; }
.small { font-size: .9rem; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--card); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }

/* ---------- Header + menu ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(241, 241, 241, .96); backdrop-filter: blur(6px); border-bottom: 1px solid rgba(138, 117, 99, .25); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; }
.brand { font-family: var(--serif); letter-spacing: .35em; text-transform: uppercase; font-size: 1.35rem; color: var(--ink-dark); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--accent); }

.menu { position: relative; }
.menu-btn {
  font: inherit; font-weight: 400; color: var(--ink-dark); background: var(--card);
  border: 1px solid rgba(138, 117, 99, .35); border-radius: 999px; padding: .5rem 1.05rem;
  display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; box-shadow: var(--shadow);
}
.menu-btn:hover { border-color: var(--accent); }
.menu-btn .chev { width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .2s; }
.menu-btn[aria-expanded="true"] .chev { transform: translateY(2px) rotate(-135deg); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .6rem); width: min(92vw, 640px);
  background: var(--card); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(78, 56, 41, .18);
  padding: 1rem 1.25rem .75rem;
  max-height: calc(100vh - 90px); overflow: auto;
}
.menu-panel[hidden] { display: none; }
.menu-unit { margin-bottom: 1rem; }
.menu-unit h2 { font-family: var(--sans); font-weight: 600; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 .35rem; }
.menu-unit h2 span { display: block; font-family: var(--serif); text-transform: none; letter-spacing: 0; font-size: 1.05rem; font-weight: 400; color: var(--ink-dark); }
.menu-unit ul { list-style: none; margin: 0; padding: 0; }
.menu-unit a { display: flex; gap: .6rem; padding: .4rem .5rem; margin: 0 -.5rem; border-radius: 6px; color: var(--ink); text-decoration: none; line-height: 1.3; }
.menu-unit a:hover, .menu-unit a:focus-visible { background: var(--bg); color: var(--accent); }
.menu-unit a[aria-current="page"] { background: var(--beige); color: var(--ink-dark); font-weight: 400; }
.menu-unit .num { color: var(--accent); font-weight: 600; min-width: 1.4rem; }
.menu-home { border-top: 1px solid var(--beige); padding-top: .6rem; margin-top: .2rem; }
.menu-home a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.menu-home a:hover { color: var(--accent); }

/* ---------- Hero / page title (deck title-slide look) ---------- */
.hero { position: relative; overflow: hidden; padding: 3.5rem 0 2.75rem; }
.hero .deco { position: absolute; right: -40px; top: -60px; width: 340px; height: 340px; pointer-events: none; }
.eyebrow { display: flex; align-items: center; gap: 1.25rem; font-family: var(--serif); text-transform: uppercase; letter-spacing: .35em; font-size: .8rem; color: var(--ink-dark); margin: 0 0 .6rem; }
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--line); max-width: 520px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--ink-dark); line-height: 1.15; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); margin: 0 0 .5rem; position: relative; }
.hero .lede { max-width: 620px; font-size: 1.1rem; margin: .5rem 0 0; position: relative; }
.hero .kicker { font-family: var(--sans); font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 .4rem; position: relative; font-weight: 400; }
.hero .kicker b { color: var(--accent); }
.authors { margin-top: 1.5rem; font-family: var(--serif); letter-spacing: .35em; text-transform: uppercase; font-size: .78rem; color: var(--ink-dark); position: relative; }

/* ---------- Lesson sections ---------- */
main { padding-bottom: 3rem; }
.lesson-section { padding: 2.25rem 0 1.75rem; border-top: 1px solid rgba(138, 117, 99, .28); }
.lesson-section:first-of-type { border-top: 0; padding-top: .5rem; }
.lesson-section > h2 { font-size: clamp(1.6rem, 3.2vw, 2.15rem); margin: 0 0 .35rem; }
.lesson-section > .sub { margin: 0 0 1rem; }
.lesson-section > * + * { margin-top: 1rem; }

.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1.5rem; align-items: start; }
.split .prose p { margin: 0 0 .8rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.card.beige, .note { background: var(--beige); }
.card h3 { font-size: 1.35rem; margin: 0 0 .35rem; color: var(--accent); }
.card h3.plain { color: var(--ink-dark); }
.card p { margin: 0; }
.card p + p { margin-top: .5rem; }
.card .label { font-weight: 600; color: var(--ink-dark); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .25rem; }
.card.center { text-align: center; }

.example { font-size: 1.2rem; font-weight: 300; }
.example .en { font-size: .95rem; }

.note { border-radius: var(--radius); padding: .85rem 1.25rem; box-shadow: var(--shadow); }
.note p { margin: 0; }
.note p + p { margin-top: .35rem; }

/* Big formula boxes: ho + guardato */
.formula { display: flex; align-items: stretch; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.formula .card { text-align: center; min-width: 200px; flex: 1 1 220px; max-width: 320px; }
.formula .big { font-family: var(--serif); font-size: 2.6rem; color: var(--accent); line-height: 1.1; display: block; }
.formula .op { align-self: center; font-size: 1.8rem; font-weight: 600; color: var(--ink-dark); }

.rule { font-family: var(--serif); font-size: 2rem; color: var(--ink-dark); display: block; margin-bottom: .4rem; }
.rule em { font-style: normal; color: var(--accent); }

/* Word chips (verbs that take essere, key words) */
.chips { display: flex; flex-wrap: wrap; gap: .6rem; list-style: none; padding: 0; margin: 0; }
.chips li { background: var(--card); border-radius: 8px; box-shadow: var(--shadow); padding: .55rem 1rem; }
.chips.big li { font-size: 1.1rem; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
caption { text-align: left; }
th, td { text-align: left; padding: .6rem 1rem; vertical-align: top; }
thead th { background: var(--beige); font-weight: 600; color: var(--ink-dark); white-space: nowrap; }
tbody tr + tr td, tbody tr + tr th { border-top: 1px solid #eeeae6; }
tbody th { font-weight: 300; color: var(--ink); white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.table-side { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; }
.table-side .card { display: flex; flex-direction: column; justify-content: center; }

/* Numbered steps (deck's dark circles) */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 2.4rem 1fr; gap: 1rem; align-items: center; counter-increment: step; }
.steps li::before {
  content: counter(step); width: 2.4rem; height: 2.4rem; border-radius: 50%;
  background: var(--ink); color: #fff; font-family: var(--serif); font-size: 1.15rem;
  display: grid; place-items: center;
}
.steps .card { padding: .85rem 1.15rem; }
.steps .card p { margin: 0; }
.steps .card .sub { font-style: italic; color: var(--muted); font-size: .95rem; margin-top: .2rem; }

/* Timeline: two tenses together */
.together { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; text-align: center; }
.together .word { font-family: var(--serif); font-size: 1.9rem; color: var(--accent); display: block; }
.together .join { font-family: var(--serif); font-size: 1.4rem; color: var(--ink-dark); }

/* Endings list -o -a -i -e */
.endings { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; font-size: 1.05rem; }
.endings b { display: inline-block; min-width: 2.2rem; }

/* Prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; }
.pager a { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; text-decoration: none; color: var(--ink); display: block; }
.pager a:hover { outline: 2px solid var(--accent); }
.pager .dir { display: block; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.pager .t { font-family: var(--serif); font-size: 1.25rem; color: var(--ink-dark); }
.pager .next { text-align: right; grid-column: 2; }

/* Home: unit cards */
.units { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.unit { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.35rem 1.4rem 1rem; }
.unit .label { font-weight: 600; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.unit h2 { font-size: 1.6rem; margin: .1rem 0 .15rem; }
.unit .theme { font-size: .9rem; color: var(--muted); margin: 0 0 .9rem; }
.unit ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--beige); }
.unit li a { display: flex; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--beige); text-decoration: none; color: var(--ink-dark); }
.unit li:last-child a { border-bottom: 0; }
.unit li a:hover { color: var(--accent); }
.unit .num { color: var(--accent); font-weight: 600; min-width: 1.5rem; }
.how { margin-top: 2.5rem; }
.how h2 { font-size: 1.9rem; margin: 0 0 1rem; }

/* Footer */
.site-footer { border-top: 1px solid rgba(138, 117, 99, .28); padding: 1.75rem 0 2.5rem; font-size: .9rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; }
.site-footer .names { font-family: var(--serif); letter-spacing: .3em; text-transform: uppercase; font-size: .75rem; color: var(--ink-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .units { grid-template-columns: 1fr 1fr; }
  .cols-4, .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-side, .split { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 1rem; }
  .wrap { padding: 0 1.1rem; }
  .brand { letter-spacing: .2em; font-size: 1.2rem; }
  .menu-panel { position: fixed; left: .75rem; right: .75rem; top: 70px; width: auto; }
  .menu-units { grid-template-columns: 1fr; }
  .menu-tabs button { flex: 1 1 auto; padding: .45rem .6rem; font-size: .85rem; }
  .units, .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .cols-4, .cols-6 { grid-template-columns: 1fr; }
  .formula { flex-direction: column; align-items: stretch; gap: .5rem; }
  .formula .card { max-width: none; flex: none; }
  .formula .op { align-self: center; }
  .toc { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .4rem; margin-right: -1.1rem; }
  .toc a { white-space: nowrap; }
  .hero { padding: 2.25rem 0 2rem; }
  .hero .deco { width: 220px; height: 220px; right: -70px; top: -50px; opacity: .7; }
  .together { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  th, td { padding: .5rem .7rem; }
  .example { font-size: 1.08rem; }
}

@media print {
  .site-header, .pager, .skip, .hero .deco { display: none; }
  body { background: #fff; }
  .card, .note, .table-wrap, .chips li { box-shadow: none; border: 1px solid #ddd; }
  .lesson-section { break-inside: avoid; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.toc li { padding: 0; box-shadow: none; background: transparent; }
.toc a { display: block; padding: .35rem .8rem; border-radius: 999px; border: 1px solid rgba(138, 117, 99, .35); background: var(--card); color: var(--ink); text-decoration: none; font-size: .85rem; }
.toc a:hover { border-color: var(--accent); color: var(--accent); }
.lesson-section { scroll-margin-top: 72px; }

/* Menu tabs */
.menu-tabs { display: flex; flex-wrap: wrap; gap: .35rem; padding: .25rem; background: var(--bg); border-radius: 999px; margin-bottom: 1rem; }
.menu-tabs button { font: inherit; font-size: .92rem; font-weight: 400; color: var(--ink); background: transparent; border: 0; border-radius: 999px; padding: .5rem .95rem; cursor: pointer; }
.menu-tabs button:hover { color: var(--accent); }
.menu-tabs button[aria-selected="true"] { background: var(--card); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.menu-units { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.menu-units[hidden] { display: none; }

/* Format switch on topic pages */
.formats { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 1.1rem 0 0; position: relative; }
.formats a { display: block; padding: .45rem 1rem; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); color: var(--ink-dark); text-decoration: none; font-size: .9rem; font-weight: 400; }
.formats a:hover { color: var(--accent); }
.formats a[aria-current="page"] { background: var(--accent); color: #fff; }
.toc { margin-top: .9rem; position: relative; }

/* Placeholder + video */
.placeholder { background: var(--card); border: 2px dashed #cfc6bc; border-radius: var(--radius); padding: 2.5rem 1.5rem; text-align: center; }
.placeholder .ph-title { font-family: var(--serif); font-size: 1.8rem; color: var(--ink-dark); margin: 0 0 .5rem; }
.placeholder p { margin: 0 auto; max-width: 560px; }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.how { margin-top: 0; margin-bottom: 2.5rem; }
@media (max-width: 640px) {
  .menu-units { grid-template-columns: 1fr; }
  .menu-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 14px; gap: .25rem; }
  .menu-tabs button { font-size: .8rem; line-height: 1.2; padding: .5rem .3rem; border-radius: 11px; }
}

/* Grammar pills (reading pages) */
.pill .prose { max-width: 72ch; margin: 0 0 .9rem; }
.pill .lesson-section > h2 + * { margin-top: .9rem; }
.pill .lesson-section > * + * { margin-top: .9rem; }
.pill .list { max-width: 72ch; margin: 0; padding-left: 1.3rem; }
.pill .list li { margin: .3rem 0; }
.pill .list li::marker { color: var(--accent); }
.pill .example + .example { margin-top: .6rem; }
.pill .part { padding: 2.5rem 0 .25rem; border-top: 2px solid var(--line); }
.pill .part:first-child { border-top: 0; padding-top: .5rem; }
.pill .part-title { font-size: clamp(1.9rem, 3.8vw, 2.6rem); margin: 0; color: var(--accent); }
.pill .lesson-section.sub > h3 { font-size: 1.5rem; margin: 0; color: var(--ink-dark); }
.pill .lesson-section.sub { padding-top: 1.5rem; }
.pill .part + .lesson-section.sub { border-top: 0; }
.pill td, .pill th { min-width: 7rem; }
.pill thead th { white-space: normal; }
@media (max-width: 640px) {
  .pill table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pill table.stack, .pill table.stack tbody, .pill table.stack tr, .pill table.stack td { display: block; width: 100%; }
  .pill table.stack tr { padding: .6rem 0; }
  .pill table.stack tbody tr + tr { border-top: 6px solid var(--bg); }
  .pill table.stack td { border: 0 !important; padding: .3rem 1rem; min-width: 0; }
  .pill table.stack td::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .pill table.stack td[data-label=""]::before { display: none; }
}
