/* -------------------------------------------------------------
   Barm or Bap - an engraved dialect atlas.
   Ink on laid paper, hatched sea, isogloss rules, a survey plate.
   ------------------------------------------------------------- */
:root {
  --paper:    #e6e3d8;   /* laid paper, warmer and dirtier than plain grey */
  --paper-2:  #f4f1e8;
  --ink:      #16211f;
  --ink-soft: #4d5a52;
  --rule:     #bdb9a6;
  --rule-2:   #d3cfbe;
  --red:      #b3372c;   /* surveyor red */
  --gold:     #9a7433;
  --land:     #d8d4c2;
}

* { box-sizing: border-box; }

/* Any author display rule beats the browser default for [hidden], so setting
   display:flex on .card silently un-hid the quiz behind the result. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Karla, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

/* Laid-paper tooth: fine chain lines, like real cartridge paper. Subtle
   enough to read as texture rather than stripes. */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: repeating-linear-gradient(
    0deg, rgba(22,33,31,.028) 0 1px, transparent 1px 4px);
}
/* Vignette, as though the plate were photographed */
body::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 35%, transparent 52%, rgba(22,33,31,.13));
}

.plate { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; }

/* -- Masthead ------------------------------------------------- */
.masthead { padding: 52px 0 34px; text-align: center; }

.rule-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.rule-row span { flex: 1; height: 0; border-top: 1px solid var(--rule); box-shadow: 0 3px 0 -2px var(--rule); }

.eyebrow {
  margin: 0; flex: none;
  font-size: 11px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--ink-soft);
}

h1 {
  font-family: Bitter, Georgia, serif;
  font-weight: 700;
  font-size: clamp(42px, 8.5vw, 76px);
  line-height: .98;
  letter-spacing: -.015em;
  margin: 0 0 16px;
  text-wrap: balance;
}
h1 em { font-style: italic; color: var(--red); }

.standfirst { margin: 0 auto; max-width: 44ch; color: var(--ink-soft); text-wrap: pretty; }

/* -- Two-up plate: map beside the survey ---------------------- */
.atlas { display: grid; grid-template-columns: 264px 1fr; gap: 40px; align-items: start; }

.map-panel { position: sticky; top: 28px; }

.map-frame {
  border: 1px solid var(--ink);
  padding: 14px;
  background: var(--paper-2);
  box-shadow: 0 0 0 4px var(--paper-2), 0 0 0 5px var(--rule);
}

#map { display: block; width: 100%; height: auto; }

.sea-line { stroke: var(--rule-2); stroke-width: .7; }
.sea { opacity: .85; }
.land { fill: var(--land); stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }

/* The Wash-Severn line, revealed when the question sitting on it is asked. */
.isogloss {
  stroke: var(--red); stroke-width: 1.2; stroke-dasharray: 5 4;
  opacity: 0; transition: opacity .5s ease;
}
.isogloss.shown { opacity: .5; }

/* One dot per region, dimming as the evidence narrows. */
.cand { transition: r .45s cubic-bezier(.2,.7,.3,1), opacity .45s ease; }
.cand-halo { transition: r .45s cubic-bezier(.2,.7,.3,1), opacity .45s ease; }

.map-caption {
  margin: 12px 0 0; text-align: center;
  font-size: 11.5px; letter-spacing: .06em; color: var(--ink-soft);
  min-height: 2.6em;
}

/* -- Cards ---------------------------------------------------- */
.card {
  min-height: 430px;
  display: flex; flex-direction: column;
  background: var(--paper-2);
  border: 1px solid var(--ink);
  padding: 30px 30px 32px;
  box-shadow: 0 0 0 4px var(--paper-2), 0 0 0 5px var(--rule);
}

/* -- Survey --------------------------------------------------- */
.progress { display: flex; gap: 4px; margin-bottom: 24px; }
.tick { height: 3px; flex: 1; background: var(--rule-2); transition: background .3s ease; }
.tick.done { background: var(--red); }

.qhead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.qnum {
  margin: 0; font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-soft);
}

.back {
  font: inherit; font-size: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--rule);
  padding: 5px 11px; color: var(--ink-soft); min-height: 32px;
}
.back:hover { border-color: var(--ink); color: var(--ink); }
.back:focus-visible { outline: 2.5px solid var(--red); outline-offset: 2px; }
.back[hidden] { display: none; }

.qtext {
  font-family: Bitter, Georgia, serif;
  font-size: clamp(24px, 3.4vw, 32px);
  line-height: 1.18; margin: 0 0 6px; text-wrap: balance;
}
.qtext em { color: var(--red); font-style: italic; }

.qsub { margin: 0 0 24px; color: var(--ink-soft); font-size: 15px; }
.qsub:empty { display: none; margin-bottom: 18px; }

.options { display: grid; gap: 8px; }
.options.dense { grid-template-columns: 1fr 1fr; }
@media (max-width: 330px) { .options.dense { grid-template-columns: 1fr; } }

/* Each option is a ruled line on a form, not a floating pill. */
.opt {
  position: relative;
  font: inherit; text-align: left; cursor: pointer;
  background: transparent;
  border: 1px solid var(--rule);
  padding: 14px 16px 14px 42px;
  color: var(--ink);
  transition: border-color .14s, background .14s;
  min-height: 50px;
}
/* An empty ballot box, filled on hover - the survey-form metaphor made literal */
.opt::before {
  content: "";
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px;
  border: 1px solid var(--rule);
  transition: background .14s, border-color .14s;
}
.opt:hover { border-color: var(--ink); background: rgba(255,255,255,.55); }
.opt:hover::before { border-color: var(--ink); background: var(--red); }
.opt:active { background: rgba(255,255,255,.8); }
.opt:focus-visible { outline: 2.5px solid var(--red); outline-offset: 2px; }

.opt.chosen { border-color: var(--ink); background: rgba(255,255,255,.6); }
.opt.chosen::before { border-color: var(--ink); background: var(--red); }

/* -- Result --------------------------------------------------- */
.result { text-align: center; justify-content: center; }
.result .verdict-label {
  font-size: 11px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 10px;
}
.result h2 {
  font-family: Bitter, Georgia, serif;
  font-size: clamp(34px, 5.4vw, 50px);
  line-height: 1.02; margin: 0 0 12px; color: var(--red);
  text-wrap: balance; letter-spacing: -.01em;
}
.result .blurb { margin: 0 auto; max-width: 34ch; color: var(--ink-soft); }

/* width:100% matters: as a flex item, the auto side-margins that centre this
   box also cancel the default stretch, so without a definite width it shrinks
   to content and the bars flex to zero. */
.runners {
  width: 100%; max-width: 340px; margin: 26px auto 0;
  border-top: 1px solid var(--rule); padding-top: 18px;
}
.runner { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 14px; }
.runner .nm { width: 140px; text-align: right; color: var(--ink-soft); flex: none; }
.runner .bar { flex: 1; height: 6px; background: var(--rule-2); overflow: hidden; }
.runner .bar span { display: block; height: 100%; background: var(--gold); transition: width .5s ease; }
.runner .pc {
  width: 34px; text-align: right; flex: none;
  font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 13px;
}

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.btn { font: inherit; cursor: pointer; padding: 13px 24px; border: 1px solid var(--ink); min-height: 48px; }
.btn-primary { background: var(--ink); color: var(--paper-2); }
.btn-primary:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: rgba(255,255,255,.6); }
.btn:focus-visible { outline: 2.5px solid var(--red); outline-offset: 2px; }

.share-note { font-size: 13px; color: var(--ink-soft); margin: 14px 0 0; min-height: 19px; }

/* -- Arriving from a shared link ------------------------------ */
.from-banner {
  margin: 0 0 26px; padding: 12px 16px;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 15px; color: var(--ink-soft); text-align: center;
}
.from-banner[hidden] { display: none; }

/* -- Colophon ------------------------------------------------- */
.colophon {
  margin: 46px auto 0; max-width: 54ch; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.source { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink-soft); }
.source a { color: var(--ink); }

.sound-toggle {
  font: inherit; font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--rule);
  padding: 7px 14px; color: var(--ink-soft); min-height: 36px;
  letter-spacing: .04em;
}
.sound-toggle:hover { border-color: var(--ink); color: var(--ink); }
.sound-toggle:focus-visible { outline: 2.5px solid var(--red); outline-offset: 2px; }
.spk { width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex: none; }
.sound-toggle[aria-pressed="false"] .spk { background: var(--rule); }

/* -- Narrow screens ------------------------------------------- */
@media (max-width: 780px) {
  .atlas { grid-template-columns: 1fr; gap: 24px; }
  /* The map stays visible above the question rather than scrolling away,
     since watching it narrow is the point. */
  .map-panel { position: sticky; top: 0; z-index: 2; padding-top: 8px; background: var(--paper); }
  .map-frame { display: flex; align-items: center; gap: 18px; padding: 12px 16px; }
  /* Big enough that the dots narrowing is actually legible - at 74px the whole
     point of the panel was invisible. */
  #map { width: 108px; flex: none; }
  .map-caption { margin: 0; text-align: left; min-height: 0; }
}

@media (max-width: 480px) {
  .plate { padding: 0 16px 64px; }
  .card { padding: 24px 20px 26px; min-height: 0; }
  .runner { font-size: 13px; }
  .runner .nm { width: 126px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
