/* mikaeel.ca design system, as plain CSS, on a cream light theme:
   Geist for text, upright Instrument Serif for accents, frosted panels
   over colourful bubbles. */
:root {
  color-scheme: light;
  --background: #faf5ea;
  --foreground: #1c1917;
  --body: #44403c;
  --muted: #78716c;
  --border: #e7e0d2;
  --ink-2: rgba(28, 25, 23, 0.6);
  --ink-3: rgba(28, 25, 23, 0.45);
  --line: rgba(28, 25, 23, 0.14);
  --line-strong: rgba(28, 25, 23, 0.32);
  --line-soft: rgba(28, 25, 23, 0.08);
  --fill: rgba(255, 255, 255, 0.55);
  --fill-2: rgba(255, 255, 255, 0.8);
  --panel: rgba(255, 253, 248, 0.6);
  --bar: #1c1917;
  --good: #15803d;
  --bad: #b91c1c;
  --sans: "Geist", Arial, Helvetica, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
em, i { font-style: normal; }
html { background: var(--background); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}
.bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.page { position: relative; z-index: 1; max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
.page.narrow { max-width: 46rem; }
@media (min-width: 768px) { .page { padding: 4.5rem 2.5rem 6rem; } }

a { color: inherit; }
.serif { font-family: var(--serif); font-style: normal; font-weight: 400; }
.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.muted { color: var(--muted); }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 3rem; }
.back { text-decoration: none; display: inline-flex; gap: 0.5rem; align-items: center; transition: color 0.15s; }
.back:hover { color: var(--foreground); }

h1 {
  font-weight: 400;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0;
}
h2 { font-weight: 400; font-size: 1.5rem; letter-spacing: -0.015em; margin: 0; line-height: 1.2; }
h3 { font-weight: 500; font-size: 1rem; margin: 0; }
.lede { margin: 0.9rem 0 0; color: var(--muted); max-width: 38rem; }

/* Frosted panel (Panel.tsx) */
.panel {
  position: relative;
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(120, 90, 40, 0.08);
  overflow: hidden;
}
.panel-body { padding: 1.5rem; }
.panel-foot {
  background: var(--fill-2);
  padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}

/* Hub */
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 2.5rem; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }
.card-link { display: block; text-decoration: none; transition: transform 0.2s, border-color 0.2s; }
.card-link:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.card-link .big { font-family: var(--serif); font-size: 4rem; line-height: 1; }
.card-wide { grid-column: 1 / -1; }
.arrow { width: 20px; height: 20px; flex-shrink: 0; }

.case { margin-top: 2.5rem; }
.case ul { margin: 0.75rem 0 0; padding-left: 1.1rem; color: var(--body); }
.case li { margin: 0.2rem 0; }
.case.twist { margin-top: 1rem; animation: rise-in 0.4s ease-out both; }
.case p { margin: 0.75rem 0 0; color: var(--body); }
/* The promotion rules: an inset box of the three criteria as tags. Comes
   after .case so its list and paragraph rules win at equal specificity. */
.rules { margin-top: 1rem; padding: 0.9rem 1rem; border: 1px solid var(--line-soft); background: var(--fill); border-radius: 16px; }
.rules ul { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rules li { margin: 0; font-size: 14px; color: var(--foreground); padding: 0.3rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--fill-2); }
.rules p { margin: 0.6rem 0 0; font-size: 13px; color: var(--muted); }

/* Survey */
.steps { display: flex; gap: 0.5rem; margin: 2rem 0 1.25rem; flex-wrap: wrap; }
.step {
  font: inherit; font-size: 13px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  border-radius: 999px; padding: 0.45rem 0.95rem; cursor: pointer;
  display: inline-flex; gap: 0.45rem; align-items: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.step:hover { color: var(--foreground); }
.step[aria-selected="true"] { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.step .tick { font-size: 11px; }

.round-intro { margin: 0.5rem 0 0; color: var(--muted); font-size: 14px; }
.evidence-row { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); display: grid; gap: 0.6rem; }
.evidence-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.evidence-btn {
  font: inherit; font-size: 14px; color: var(--foreground); cursor: pointer;
  background: var(--fill-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.5rem 1rem; display: inline-flex; align-items: center; gap: 0.5rem;
  transition: border-color 0.15s, transform 0.15s;
}
.evidence-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.evidence-btn:focus-visible, .modal button:focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }

.modal {
  border: 1px solid var(--line); border-radius: 24px; padding: 0;
  width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  background: #fffdf8; color: var(--foreground);
  box-shadow: 0 24px 64px rgba(120, 90, 40, 0.22);
}
.modal[open] { animation: pop 0.2s ease-out; }
.modal::backdrop { background: rgba(28, 25, 23, 0.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal-body { padding: 1.5rem 1.5rem 1.25rem; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.modal h2 { margin-top: 0.35rem; }
.modal-x {
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-2);
  background: none; border: 1px solid var(--line); border-radius: 50%; width: 2.25rem; height: 2.25rem; flex-shrink: 0;
}
.modal-x:hover { color: var(--foreground); border-color: var(--line-strong); }
.modal.wide { width: min(56rem, calc(100vw - 2rem)); }
.pdf { margin: 1.25rem 0 0; }
.pdf-frame {
  height: min(70vh, 54rem); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; background: #fff;
}
.pdf-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.pdf figcaption {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-top: 0.75rem; font-size: 12px; color: var(--ink-3);
}
.doc-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

form { margin: 0; }
.field { margin-top: 1.75rem; }
.field > label, .field > .q { display: block; font-size: 15px; margin-bottom: 0.6rem; }
.field .hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 0.2rem; }
.fill-in { display: grid; gap: 0.6rem; }
.fill-in .stem { font-size: 12px; color: var(--ink-2); margin-bottom: 0.3rem; }
textarea, input[type="text"] {
  width: 100%;
  font: inherit; font-size: 15px; color: var(--foreground);
  background: var(--fill); border: 1px solid var(--line);
  border-radius: 14px; padding: 0.75rem 0.9rem;
  resize: vertical; min-height: 3rem;
  transition: border-color 0.15s, background 0.15s;
}
textarea { min-height: 5.5rem; }
textarea:focus, input:focus { outline: none; border-color: var(--line-strong); background: var(--fill-2); }
textarea::placeholder, input::placeholder { color: var(--ink-3); }

.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-block; cursor: pointer; font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px; padding: 0.5rem 1rem;
  color: var(--body); transition: all 0.15s;
}
.choice span:hover { border-color: var(--line-strong); }
.choice input:checked + span { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.choice input:focus-visible + span { outline: 2px solid var(--foreground); outline-offset: 2px; }

fieldset.field { border: 0; padding: 0; margin-left: 0; margin-right: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 0.6rem; font-size: 15px; }
.choices.scale { display: grid; grid-template-columns: repeat(5, 1fr); max-width: 22rem; }
.choices.scale .choice span { display: block; text-align: center; padding: 0.5rem 0; }
.scale-ends { display: flex; justify-content: space-between; max-width: 22rem; margin-top: 0.4rem; font-size: 12px; color: var(--ink-3); gap: 1rem; }
.practice { margin-top: 1.75rem; border-top: 1px solid var(--line-soft); padding-top: 1.25rem; }

.actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: 14px; font-weight: 500;
  border-radius: 999px; padding: 0.7rem 1.4rem; cursor: pointer;
  border: 1px solid var(--foreground); background: var(--foreground); color: var(--background);
  transition: opacity 0.15s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; color: var(--foreground); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--line-strong); opacity: 1; }
.btn.small { font-size: 12px; padding: 0.4rem 0.9rem; }
.status { font-size: 13px; color: var(--ink-2); min-height: 1.2em; }
.status.ok { color: var(--good); }
.status.err { color: var(--bad); }

.done {
  text-align: center; padding: 2.5rem 1.5rem;
  animation: rise-in 0.35s ease-out;
}
.done .serif { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }

/* Analytics */
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 2rem 0 1rem; }
.toolbar .spacer { flex: 1; }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat .num { font-size: 2.5rem; letter-spacing: -0.02em; line-height: 1.1; margin-top: 0.35rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--ink-3); margin-top: 0.15rem; }

.charts { display: grid; gap: 1rem; margin-top: 1rem; }
@media (min-width: 900px) { .charts { grid-template-columns: 1fr 1fr; } }
.chart h3 { margin-bottom: 0.2rem; }
.chart .caption { font-size: 12px; color: var(--ink-3); margin-bottom: 1rem; }
.bars { display: grid; gap: 0.55rem; }
.bar-row { display: grid; grid-template-columns: minmax(7rem, 38%) 1fr 2.2rem; gap: 0.75rem; align-items: center; font-size: 13px; position: relative; }
.bar-row .name { color: var(--body); line-height: 1.3; overflow-wrap: anywhere; }
.bar-track { height: 14px; position: relative; }
.bar-track::before { content: ""; position: absolute; inset: 6px 0; background: var(--line-soft); border-radius: 2px; }
.bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0; min-width: 0;
  background: var(--bar); border-radius: 0 4px 4px 0;
  transform-origin: left; animation: grow-x 0.5s ease-out;
}
@media (max-width: 560px) {
  .bar-row { grid-template-columns: 1fr 2.2rem; row-gap: 0.2rem; }
  .bar-row .name { grid-column: 1 / -1; white-space: normal; }
}
.bar-row:hover .bar-fill { background: #57534e; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--foreground); }
.empty { font-size: 13px; color: var(--ink-3); padding: 0.5rem 0; }

.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 10px;
  padding: 0.45rem 0.65rem; font-size: 12px; color: var(--foreground);
  box-shadow: 0 8px 24px rgba(120, 90, 40, 0.15); opacity: 0; transition: opacity 0.1s;
  max-width: 16rem;
}
.tip.on { opacity: 1; }

.round-section { margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.round-title { margin-top: 0.3rem; font-size: 2rem; }
.round-title .serif { font-size: 1.25rem; }
.subhead { margin: 1.75rem 0 0; font-weight: 400; }
.qblock { margin-top: 1rem; }
.qblock summary {
  list-style: none; cursor: pointer; padding: 1.1rem 1.5rem;
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
}
.qblock summary::-webkit-details-marker { display: none; }
.qblock summary .count { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.qblock[open] summary { border-bottom: 1px solid var(--line-soft); }
.qlist { padding: 0.5rem 1.5rem 1.25rem; display: grid; gap: 0.25rem; }
.qitem { padding: 0.75rem 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; color: var(--foreground); white-space: pre-wrap; overflow-wrap: anywhere; }
.qitem:last-child { border-bottom: 0; }
.qitem .who { display: block; margin-bottom: 0.25rem; }

.tabs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabs-table th, .tabs-table td { text-align: left; padding: 0.5rem 0.25rem; border-bottom: 1px solid var(--line-soft); }
.tabs-table th { font-weight: 400; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.tabs-table td.n { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.foot { margin-top: 4rem; font-size: 12px; color: var(--ink-3); }

@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.rise { animation: rise-in 0.4s ease-out both; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
