/* Shakespeare IDL – Venice & the Elizabethan stage: paper, ink, oxblood, lagoon, gold */
:root {
  --bg: #f6f1e6;
  --paper: #fffdf7;
  --ink: #241c15;
  --muted: #6b5e50;
  --line: #e2d8c4;
  --accent: #8a2432;      /* oxblood – curtain, seal */
  --accent-soft: #f3e1e1;
  --lagoon: #2c5f66;      /* Venetian lagoon */
  --lagoon-soft: #e1eeee;
  --gold: #a9802f;        /* ducats */
  --gold-soft: #f6ecd6;
  --ok: #2f6b3a;
  --ok-soft: #e3f0e3;
  --bad: #9a2f2f;
  --bad-soft: #f6e2e0;
  --shadow: 0 1px 2px rgba(36, 28, 21, .06), 0 4px 16px rgba(36, 28, 21, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
/* dark theme only on request (toggle in the top bar) */
:root[data-theme="dark"] {
    --bg: #15110e;
    --paper: #1f1914;
    --ink: #eee4d4;
    --muted: #b1a390;
    --line: #3a3029;
    --accent: #d36a77;
    --accent-soft: #3a1f23;
    --lagoon: #7bbcc1;
    --lagoon-soft: #1d3234;
    --gold: #d6b26a;
    --gold-soft: #33291a;
    --ok: #8fc79a;
    --ok-soft: #1f3324;
    --bad: #e08a80;
    --bad-soft: #3a2220;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
}
button, input, textarea, select { font: inherit; color: inherit; }
button, a, summary, label, .vocab { touch-action: manipulation; }
a { color: var(--lagoon); }
p { margin: 0 0 .8em; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 2rem; letter-spacing: .01em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
.sans { font-family: var(--sans); }
.muted { color: var(--muted); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 18px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 8px; min-height: 56px; }
.brand {
  font-family: var(--serif); font-weight: 600; font-size: 1.05rem;
  color: var(--ink); text-decoration: none; margin-right: auto;
  display: flex; align-items: center; gap: 8px; min-height: 44px;
}
.brand svg { width: 26px; height: 26px; }
.navbtn {
  font-family: var(--sans); font-size: .85rem;
  min-height: 44px; min-width: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.navbtn[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) { .navbtn .lbl { display: none; } }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 60%),
    linear-gradient(160deg, #2b1416 0%, #5e1a26 45%, #1f3f45 100%);
  color: #f6ecdb;
  padding: 44px 0 40px;
}
.hero::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 46px;
  background:
    radial-gradient(28px 10px at 28px 46px, transparent 26px, rgba(255,255,255,.07) 27px, transparent 29px) 0 0 / 56px 46px repeat-x;
  pointer-events: none;
}
.hero .wrap { position: relative; z-index: 1; }
.hero .kicker { font-family: var(--sans); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.hero h1 { color: #fff7ea; margin-top: .2em; }
.hero .question { font-size: 1.3rem; font-style: italic; max-width: 40ch; opacity: .95; }
.hero .source { font-family: var(--sans); font-size: .85rem; opacity: .75; }
.hero-art { position: absolute; right: -10px; bottom: 0; width: 360px; max-width: 55%; opacity: .22; pointer-events: none; }
.hero .meta { font-family: var(--sans); font-size: .9rem; opacity: .85; display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- cards & layout ---------- */
main { padding: 26px 0 120px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin: 0 0 18px;
}
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.chip {
  font-family: var(--sans); font-size: .75rem; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.chip.op { background: var(--accent-soft); color: var(--accent); border-color: transparent; text-transform: uppercase; font-weight: 600; }
.chip.mode { background: var(--lagoon-soft); color: var(--lagoon); border-color: transparent; }
.chip.time { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.btn {
  font-family: var(--sans); font-size: .95rem; font-weight: 600;
  min-height: 44px; padding: 0 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- start page ---------- */
.banner {
  font-family: var(--sans); font-size: .92rem;
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px;
  background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
}
.banner.warn { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.unlock { display: flex; gap: 10px; flex-wrap: wrap; }
.unlock input {
  flex: 1 1 200px; min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); text-transform: uppercase; letter-spacing: .08em;
  font-family: var(--sans);
}
.block-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 10px; }
.block-head .num { font-family: var(--sans); font-size: .8rem; color: var(--accent); letter-spacing: .12em; text-transform: uppercase; }
.sessions { display: grid; gap: 10px; }
.session-link {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 16px; min-height: 64px; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line);
}
.session-link .when { font-family: var(--sans); font-size: .78rem; color: var(--muted); line-height: 1.3; }
.session-link .t { font-weight: 600; }
.session-link .q { font-size: .9rem; color: var(--muted); }
.session-link.locked { opacity: .55; }
.session-link.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.session-link .state { font-family: var(--sans); font-size: .8rem; color: var(--muted); }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }

/* ---------- session ---------- */
.goals li { margin-bottom: .3em; }
.agenda { list-style: none; padding: 0; margin: 0; counter-reset: ag; }
.agenda li {
  display: grid; grid-template-columns: 30px 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-family: var(--sans); font-size: .92rem;
}
.agenda li:last-child { border-bottom: 0; }
.agenda li::before { counter-increment: ag; content: counter(ag); font-weight: 700; color: var(--accent); text-align: center; }
.sec-label { font-family: var(--sans); font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }

.play { border-left: 4px solid var(--accent); }
.play .intro { font-style: italic; color: var(--muted); }
.lines { margin: 12px 0; }
.line { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 1px 0; }
.line .sp { font-family: var(--sans); font-size: .76rem; font-weight: 700; letter-spacing: .06em; color: var(--accent); padding-top: .35em; }
.line.sd .tx { font-style: italic; color: var(--muted); }
.line.cut .tx { color: var(--muted); }
@media (max-width: 560px) { .line { grid-template-columns: 1fr; gap: 0; } .line .sp { padding-top: .6em; } }
.modern { background: var(--lagoon-soft); border-radius: 10px; padding: 12px 14px; margin-top: 8px; }

details { border-top: 1px solid var(--line); margin-top: 10px; }
details > summary {
  cursor: pointer; list-style: none; font-family: var(--sans); font-size: .9rem; font-weight: 600;
  color: var(--lagoon); min-height: 44px; display: flex; align-items: center; gap: 8px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details .inner { padding: 4px 0 8px; }

.task .prompt { font-size: 1.08rem; }
.roles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 10px 0; }
.role { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.role b { display: block; font-family: var(--sans); font-size: .9rem; color: var(--lagoon); }
.output { font-family: var(--sans); font-size: .9rem; background: var(--gold-soft); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }

textarea, .short-input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  padding: 12px 14px; line-height: 1.55; resize: vertical; font-family: var(--serif); font-size: 1rem;
}
textarea:focus, .short-input:focus, .unlock input:focus { outline: 2px solid var(--lagoon); outline-offset: 1px; }
.short-input { min-height: 44px; }
.write-meta { display: flex; justify-content: space-between; gap: 10px; font-family: var(--sans); font-size: .78rem; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }

.debate { border: 2px solid var(--accent); }
.motion { font-size: 1.25rem; font-style: italic; margin: 6px 0 12px; }
.steps { list-style: none; padding: 0; margin: 10px 0; }
.steps li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-family: var(--sans); font-size: .92rem; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-family: var(--sans); font-size: .92rem; }
.check input { width: 22px; height: 22px; }

.spectrum-bar { position: relative; height: 14px; border-radius: 99px; margin: 18px 0 6px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--lagoon)); }
.spectrum-labels { display: flex; justify-content: space-between; gap: 20px; font-family: var(--sans); font-size: .9rem; font-weight: 600; }

.box { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; border: 1px solid var(--line); }
.box.tip { background: var(--lagoon-soft); }
.box.info { background: var(--gold-soft); }
.box.context { background: var(--accent-soft); }

.opt { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); margin: 6px 0; cursor: pointer; background: var(--bg); }
.opt input { width: 22px; height: 22px; margin-top: 3px; flex: none; }
.opt.right { background: var(--ok-soft); border-color: var(--ok); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.feedback { font-family: var(--sans); font-size: .9rem; margin-top: 6px; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--bad); }
.qitem { margin-bottom: 14px; }

.media { display: flex; gap: 14px; align-items: flex-start; }
.media .ico { font-size: 1.6rem; line-height: 1; }

.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; }

.plan { margin: 4px 0 0; padding-left: 1.4em; font-family: var(--sans); font-size: .95rem; columns: 2 220px; column-gap: 28px; }
.plan li { margin-bottom: 4px; break-inside: avoid; }
.plan li::marker { color: var(--accent); font-weight: 700; }
.words details { border-top: 0; margin-top: 0; }
.words summary { color: var(--accent); }
.search { position: sticky; top: 64px; z-index: 5; margin-bottom: 12px; }
.search input { width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); font-family: var(--sans); font-size: 1rem; box-shadow: var(--shadow); }
.search input:focus { outline: 2px solid var(--lagoon); }
.search p { font-size: .82rem; margin: 6px 4px 0; min-height: 1em; }
.gl-item[hidden], .gl-group[hidden] { display: none; }

/* images, tables, scenes */
.figure { padding: 14px; }
.figure img { display: block; width: auto; max-width: 100%; height: auto; max-height: min(55vh, 440px); margin: 0 auto; border-radius: 10px; }
.figure figcaption { font-size: .95rem; margin-top: 10px; }
.figure .credit { display: block; font-family: var(--sans); font-size: .75rem; color: var(--muted); margin-top: 4px; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.cmp { width: 100%; border-collapse: collapse; font-size: .98rem; }
table.cmp th { text-align: left; font-family: var(--sans); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); border-bottom: 2px solid var(--line); padding: 8px 10px; }
table.cmp td { border-bottom: 1px dashed var(--line); padding: 8px 10px; vertical-align: top; }
table.cmp tr:last-child td { border-bottom: 0; }
.scene { border-left: 4px solid var(--lagoon); }
.scene .intro { font-style: italic; color: var(--muted); }

/* vocabulary tap */
.vocab {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 2px dotted var(--gold); border-radius: 0;
}
.vocab:focus-visible { outline: 2px solid var(--lagoon); }
.defbar {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, calc(100% + 40px)); z-index: 50;
  width: min(640px, calc(100% - 24px)); background: var(--ink); color: var(--bg);
  border-radius: 14px; padding: 12px 52px 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  transition: transform .2s ease, visibility .2s; visibility: hidden;
}
.defbar.show { transform: translate(-50%, 0); visibility: visible; }
.defbar b { font-family: var(--serif); }
.defbar .x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: transparent; color: inherit; font-size: 1.2rem; cursor: pointer; }

/* floating timer */
.timer {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; display: none;
  font-family: var(--sans); background: var(--paper); border: 2px solid var(--accent);
  border-radius: 16px; padding: 8px 10px 8px 16px; box-shadow: var(--shadow); align-items: center; gap: 8px;
}
.timer.on { display: flex; }
.timer .clock { font-size: 1.5rem; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 74px; }
.timer.done { animation: pulse 1s ease-in-out 4; background: var(--accent-soft); }
@keyframes pulse { 50% { transform: scale(1.05); } }
.timer button { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }

/* glossary & toolkit */
.gloss-letter { font-family: var(--sans); color: var(--accent); font-weight: 700; margin: 18px 0 6px; }
.gloss dl { margin: 0; }
.gloss dt { font-weight: 600; }
.gloss dd { margin: 0 0 10px; color: var(--muted); }
.device.locked { opacity: .5; }
.device h3 { margin-bottom: .2em; }

.fade { animation: fadein .35s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade, .timer.done { animation: none; } .defbar { transition: none; } }

/* print: only the writing export */
@media print {
  .topbar, .hero, .noprint, .timer, .defbar { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-entry { break-inside: avoid; margin-bottom: 14pt; }
}
