/* layout — structure only. No colour, no typeface, no texture: those live in
   css/look-*.css and reach this file as custom properties. Phone is the
   base case; the desktop rules are the exception at the bottom. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

.wrap { width: 100%; max-width: 34rem; margin: 0 auto; padding: 0 1.1rem; }

/* ---------------------------------------------------------------- type roles */

.eyebrow {
  font-family: var(--type-mono);
  font-size: 0.6rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.9rem;
}
h1, h2, h3 {
  font-family: var(--type-display);
  font-weight: var(--weight-display);
  letter-spacing: var(--tracking-display);
  line-height: 1.08;
  margin: 0;
}
h1 { font-size: clamp(2.1rem, 10vw, 3.2rem); }
h2 { font-size: clamp(1.35rem, 5.6vw, 2.1rem); margin-bottom: 0.55rem; }
h3 { font-size: 1.02rem; letter-spacing: 0.02em; }
p { margin: 0 0 1rem; }
.lede { font-size: 1.06rem; color: var(--ink-dim); }
.small { font-size: 0.85rem; line-height: 1.55; color: var(--ink-dim); }
.mono { font-family: var(--type-mono); font-size: 0.78rem; letter-spacing: 0.01em; }
b, strong { font-weight: var(--weight-strong); color: var(--ink); }
em { font-style: italic; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* ------------------------------------------------------------------ sections */

section { padding: 2.5rem 0; border-top: 1px solid var(--rule); }
section:first-of-type { border-top: 0; }

/* ------------------------------------------------------------- 1. the opening */

.hook { padding-top: 3.4rem; padding-bottom: 2.4rem; }
.hook h1 { margin-bottom: 1.05rem; }
.hook .lede { margin-bottom: 1.1rem; color: var(--ink); }

/* --------------------------------------------------------------- 2. the graph */

.graphwrap { padding-bottom: 1rem; }
.figurehead { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.tally {
  display: flex; flex-wrap: wrap; gap: 0.1rem 1.1rem;
  font-family: var(--type-mono); font-size: 0.68rem; color: var(--ink-faint);
  margin: 0.2rem 0 1rem;
}
.tally b { color: var(--ink); font-weight: var(--weight-strong); }

.controls { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.7rem; }
.controls button {
  font-family: var(--type-mono); font-size: 0.64rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.4rem 0.6rem; cursor: pointer;
  background: transparent; color: var(--ink-faint);
  border: 1px solid var(--rule-bright); border-radius: var(--radius);
  min-height: 30px;
}
.controls button[aria-pressed="true"] { color: var(--ground); background: var(--accent); border-color: var(--accent); }

#graph { display: block; width: 100%; touch-action: manipulation; }
#graph text { user-select: none; }
#graph .hit { cursor: pointer; }

.legend {
  display: flex; flex-wrap: wrap; gap: 0.3rem 1rem;
  font-family: var(--type-mono); font-size: 0.64rem; color: var(--ink-faint);
  margin: 0.7rem 0 0;
}
.legend span { display: inline-flex; align-items: center; gap: 0.36rem; }
.legend i {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none;
  border: 1px solid currentColor;
}

/* the detail: a bottom sheet on a phone, a column on a desktop */
#detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 66vh; overflow-y: auto;
  background: var(--ground-lift);
  border-top: 1px solid var(--rule-bright);
  box-shadow: var(--sheet-shadow);
  transform: translateY(101%);
  transition: transform 0.22s ease;
  padding: 0.9rem 1.1rem calc(1.4rem + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
#detail[data-open="1"] { transform: translateY(0); }
#detail .close {
  position: sticky; top: 0; float: right; margin: -0.2rem -0.3rem 0 0;
  background: var(--ground-lift); border: 0; color: var(--ink-faint); cursor: pointer;
  font-family: var(--type-mono); font-size: 0.95rem; padding: 0.25rem 0.5rem; min-height: 34px;
}
.d-path { font-family: var(--type-mono); font-size: 0.66rem; letter-spacing: 0.16em; color: var(--ink-faint); }
.d-title { font-family: var(--type-display); font-size: 1.4rem; font-weight: var(--weight-display); letter-spacing: var(--tracking-display); margin: 0.15rem 0 0.5rem; }
.d-char { font-family: var(--type-body); font-style: italic; color: var(--accent); margin: 0 0 0.8rem; }
.d-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.55rem 0.9rem;
  margin: 0.9rem 0; padding: 0.8rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.d-grid div { min-width: 0; }
.d-grid dt { font-family: var(--type-mono); font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.d-grid dd { margin: 0.1rem 0 0; font-family: var(--type-mono); font-size: 0.85rem; overflow-wrap: anywhere; }
.d-brief { font-size: 0.92rem; color: var(--ink-dim); border-left: 2px solid var(--rule-bright); padding-left: 0.8rem; margin: 0 0 0.9rem; }
.d-files { list-style: none; margin: 0.35rem 0 0.9rem; padding: 0; font-family: var(--type-mono); font-size: 0.72rem; color: var(--ink-dim); }
.d-files li { overflow-wrap: anywhere; padding: 0.1rem 0; }
.d-flag { font-family: var(--type-mono); font-size: 0.66rem; letter-spacing: 0.05em; padding: 0.25rem 0.45rem; border: 1px solid currentColor; border-radius: var(--radius); display: inline-block; margin: 0 0 0.8rem; }

/* ------------------------------------------------------------------ 3. panels */

.card {
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1.1rem; margin: 0 0 0.9rem; background: var(--ground-sink);
}
.card h3 { margin-bottom: 0.45rem; }
.card .n { font-family: var(--type-mono); font-size: 0.6rem; letter-spacing: 0.18em; color: var(--ink-faint); display: block; margin-bottom: 0.4rem; }
.card p:last-child { margin-bottom: 0; }
.stack { display: grid; gap: 0; }

.hole {
  display: inline-block; font-family: var(--type-mono); font-size: 0.74rem;
  color: var(--state-pending); border: 1px dashed var(--state-pending);
  padding: 0.28rem 0.5rem; border-radius: var(--radius);
}

.note { border-left: 2px solid var(--accent); padding-left: 0.9rem; margin: 1.3rem 0; }
.note p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ desktop */

@media (min-width: 860px) {
  body { font-size: 18px; }
  .wrap { max-width: 62rem; padding: 0 2rem; }
  .hook .wrap, .theses .wrap, .shape .wrap { max-width: 42rem; }
  section { padding: 5rem 0; }

  .graphwrap .wrap { max-width: 74rem; }
  .stage { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 2rem; align-items: start; }
  #detail {
    position: sticky; top: 1.5rem; transform: none; max-height: calc(100vh - 3rem);
    border: 1px solid var(--rule-bright); border-radius: var(--radius); box-shadow: none;
    padding: 1.1rem 1.2rem 1.4rem;
  }
  #detail .close { display: none; }
  .d-grid { grid-template-columns: repeat(2, 1fr); }
  .theses .stack { grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
  .theses .card { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #detail { transition: none; }
}

/* the simulated-depth caption sits under the controls, in the warning colour */
.simcap {
  border-left: 2px solid var(--state-pending);
  padding-left: 0.8rem;
  margin: 0 0 0.8rem;
}
.controls button[disabled] { opacity: 0.35; cursor: not-allowed; }
