/* Spektral-Q: Survey Sheet design system.
   Every font size and every margin, padding and gap uses the tokens below (see CLAUDE.md). */

@font-face { font-family: "Spectral"; src: url("fonts/spectral-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/spectral-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/spectral-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atkinson Mono"; src: url("fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  /* Colour */
  --sheet: #F5F6F3;
  --sheet-shade: #E9ECE6;
  --ink: #000000;
  --graphite: #4B524C;
  --rule: #B9C0B8;
  --water: #2438A6;
  --redline: #B3261E;

  /* Type: voice, instrument, values */
  --voice: "Spectral", Georgia, "Times New Roman", serif;
  --instrument: "Atkinson Next", "Segoe UI", Arial, sans-serif;
  --values: "Atkinson Mono", Consolas, monospace;

  /* Type scale (desktop / mobile) */
  --fs-thesis: clamp(36px, 3vw + 18px, 60px);
  --fs-h2: clamp(24px, 1vw + 18px, 32px);
  --fs-h3: clamp(20px, 0.25vw + 18px, 22px);
  --fs-lead: clamp(19px, 0.4vw + 16px, 22px);
  --fs-body: clamp(18px, 0.1vw + 17.5px, 19px);
  --fs-ui: 16px;
  --fs-value: 15px;
  --fs-caption: 14px;

  /* Spacing scale */
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 40px;
  --s-5: 64px;
  --s-6: 104px;

  --gutter: clamp(var(--s-2), 4vw, var(--s-5));
  --tap: 44px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--s-5) + var(--s-3)); }
body {
  margin: 0;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--voice);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

a { color: var(--water); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a[href^="mailto:"] { overflow-wrap: anywhere; }   /* long addresses may break on narrow phones */
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
button { font: inherit; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: var(--sheet); padding: var(--s-1) var(--s-2); font-family: var(--instrument); font-size: var(--fs-ui); z-index: 10; }
.skip:focus { left: var(--s-2); top: var(--s-2); }

/* ---------- Masthead ---------- */
.masthead { position: sticky; top: 0; z-index: 5; background: var(--sheet); border-bottom: 1px solid var(--rule); }
.masthead__inner {
  max-width: 1320px; margin: 0 auto; padding: var(--s-2) var(--gutter);
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
}
.wordmark { font-family: var(--voice); font-weight: 500; font-size: var(--fs-h3); line-height: 1.2; color: var(--ink); text-decoration: none; }
.wordmark small { display: block; font-family: var(--instrument); font-size: var(--fs-caption); font-weight: 400; color: var(--graphite); margin-top: var(--s-1); }
.nav { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; font-family: var(--instrument); font-size: var(--fs-ui); }
.nav a { color: var(--ink); text-decoration: none; padding: var(--s-1) 0; border-bottom: 1px solid transparent; }
.nav a:hover { border-bottom-color: var(--ink); }
.nav a.nav__cta { border: 1px solid var(--ink); border-radius: 4px; padding: var(--s-1) var(--s-2); }
.nav a.nav__cta:hover { background: var(--ink); color: var(--sheet); }

/* ---------- Mobile menu: a contents sheet dropping from the masthead ---------- */
.menu-btn { display: none; }
.menu {
  margin: 0; inset: 0 0 auto; width: 100%; max-width: none; max-height: 100dvh; overflow-y: auto;
  padding: 0 var(--gutter) var(--s-3); border: 0; border-bottom: 2px solid var(--ink);
  background: var(--sheet); color: var(--ink); font-family: var(--instrument);
}
.menu::backdrop { background: rgba(0, 0, 0, 0.35); }
.menu[open] { animation: menu-drop 0.25s var(--ease); }
@keyframes menu-drop { from { transform: translateY(-12px); opacity: 0; } }
.menu__head { display: flex; justify-content: space-between; align-items: center; min-height: var(--s-5); border-bottom: 1px solid var(--rule); font-family: var(--voice); font-size: var(--fs-h3); font-weight: 500; }
.menu__close, .menu-btn {
  font-family: var(--instrument); font-size: var(--fs-ui); font-weight: 600; color: var(--ink);
  background: none; border: 1px solid var(--ink); border-radius: 4px; min-height: var(--tap); padding: 0 var(--s-2); cursor: pointer;
}
.menu ol { list-style: none; margin: 0; padding: 0; }
.menu li { border-bottom: 1px solid var(--rule); }
.menu li:last-child { border-bottom: 0; }
.menu li a { display: flex; gap: var(--s-2); align-items: center; min-height: calc(var(--tap) + var(--s-1)); color: var(--ink); text-decoration: none; font-size: var(--fs-body); }
.menu li a span { font-family: var(--values); font-size: var(--fs-value); color: var(--graphite); min-width: 2.6em; }
.menu li:last-child a { font-weight: 600; }
.menu__also { margin: var(--s-2) 0 0; padding-top: var(--s-2); border-top: 2px solid var(--ink); font-size: var(--fs-ui); color: var(--graphite); }
.menu__also a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }

/* ---------- Sheet layout: main field and margin column ---------- */
.sheet {
  max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter);
  display: grid; grid-template-columns: minmax(0, 9fr) minmax(0, 3fr); column-gap: var(--s-5);
}
.sheet > main { grid-column: 1; min-width: 0; }
.sheet > aside { grid-column: 2; }
.margin-card {
  position: sticky; top: calc(var(--s-6) - var(--s-1));
  margin-top: var(--s-5); padding-top: var(--s-2);
  font-family: var(--instrument); font-size: var(--fs-caption); line-height: 1.45; color: var(--graphite);
  border-top: 2px solid var(--ink);
}
.margin-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-2); }
.margin-card dd { margin: 0; color: var(--ink); font-family: var(--values); font-size: var(--fs-caption); }
.margin-card dd.text { font-family: var(--instrument); }
.margin-card ol { margin: var(--s-2) 0 0; padding: 0; list-style: none; }
.margin-card ol a { color: var(--ink); text-decoration: none; display: block; padding: var(--s-1) 0; }
.margin-card ol a:hover { text-decoration: underline; }

/* ---------- Hero ---------- */
.hero { padding: var(--s-5) 0 var(--s-4); border-bottom: 1px solid var(--rule); }
.hero h1 { font-weight: 400; font-size: var(--fs-thesis); line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 var(--s-3); max-width: 18ch; }
.hero .lede { font-size: var(--fs-lead); line-height: 1.5; max-width: 60ch; margin: 0 0 var(--s-2); }
.hero .actions { margin-top: var(--s-3); }
.hero figure { margin: var(--s-4) 0 0; }

/* ---------- Sections ---------- */
.sec { padding: var(--s-5) 0 var(--s-3); border-bottom: 1px solid var(--rule); }
.sec:last-of-type { border-bottom: 0; }
.sec h2 { font-weight: 500; font-size: var(--fs-h2); line-height: 1.2; margin: 0 0 var(--s-3); display: flex; gap: var(--s-2); align-items: baseline; }
.sec h2 .no { font-family: var(--values); font-weight: 400; font-size: var(--fs-value); color: var(--graphite); min-width: 2.6em; flex: none; }
.sec h3 { font-weight: 500; font-size: var(--fs-h3); line-height: 1.3; margin: var(--s-4) 0 var(--s-1); }
:where(.sec) p, :where(.sec) ul, :where(.sec) ol { max-width: 68ch; }
:where(.sec) p { margin: 0 0 var(--s-2); }
:where(.sec) ul { padding-left: 1.2em; margin: 0 0 var(--s-2); }
:where(.sec) li { margin-bottom: var(--s-1); }
:where(.sec) li::marker { color: var(--graphite); }
.lead { font-size: var(--fs-lead); line-height: 1.5; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: var(--s-3) 0 var(--s-1); }
table { border-collapse: collapse; width: 100%; font-family: var(--instrument); font-size: var(--fs-ui); line-height: 1.45; }
caption { text-align: left; font-family: var(--instrument); font-size: var(--fs-caption); color: var(--graphite); padding-bottom: var(--s-1); }
th, td { text-align: left; vertical-align: top; padding: var(--s-2) var(--s-2) var(--s-2) 0; border-top: 1px solid var(--rule); }
thead th { font-weight: 600; border-top: 2px solid var(--ink); }
tbody th { font-family: var(--voice); font-weight: 500; font-size: var(--fs-body); width: 26%; }

/* ---------- Sequences: layers, gates, steps ---------- */
.steps { list-style: none; padding: 0; margin: var(--s-3) 0; max-width: none; display: grid; }
.steps > li { display: grid; grid-template-columns: var(--s-5) minmax(0, 1fr); gap: var(--s-3); padding: var(--s-2) 0; border-top: 1px solid var(--rule); margin: 0; }
.steps > li:last-child { border-bottom: 1px solid var(--rule); }
.steps .k { font-family: var(--values); font-size: var(--fs-value); color: var(--ink); padding-top: var(--s-1); }
.steps h3 { margin: 0 0 var(--s-1); }
.steps p { margin: 0 0 var(--s-1); font-family: var(--instrument); font-size: var(--fs-ui); line-height: 1.5; }
.steps .out { color: var(--graphite); }
.steps .out b { font-weight: 600; color: var(--ink); }

.gates { list-style: none; padding: 0; margin: var(--s-3) 0 var(--s-2); max-width: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: var(--s-2); counter-reset: gate; }
.gates li { counter-increment: gate; position: relative; padding-top: var(--s-4); margin: 0; font-family: var(--instrument); font-size: var(--fs-caption); line-height: 1.4; }
.gates li::before { content: ""; position: absolute; top: 11px; left: 0; right: calc(-1 * var(--s-2)); height: 1px; background: var(--ink); }
.gates li::after { content: counter(gate); position: absolute; top: 0; left: 0; width: 22px; height: 22px; border: 1px solid var(--ink); border-radius: 50%; background: var(--sheet); font-family: var(--values); font-size: var(--fs-caption); display: grid; place-items: center; }
.gates li:last-child::before { right: auto; width: 22px; }
.gates b { display: block; font-weight: 600; font-size: var(--fs-ui); margin-bottom: var(--s-1); }
.gates span { color: var(--graphite); }

/* ---------- Figures ---------- */
figure { margin: var(--s-4) 0; }
figure svg { display: block; width: 100%; height: auto; }
figcaption { font-family: var(--instrument); font-size: var(--fs-caption); color: var(--graphite); margin-top: var(--s-2); max-width: 72ch; }
figcaption b { color: var(--ink); font-weight: 600; }
.legend, .callouts { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); margin: var(--s-2) 0 0; padding: 0; list-style: none; font-family: var(--instrument); font-size: var(--fs-caption); max-width: none; }
.legend { color: var(--graphite); }
.legend li, .callouts li { display: flex; align-items: center; gap: var(--s-1); margin: 0; }
.legend svg { width: 22px; height: 14px; flex: none; }
.callouts { counter-reset: co; }
.callouts li { counter-increment: co; }
.callouts li::before { content: counter(co); flex: none; width: 20px; height: 20px; border: 1px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font-family: var(--values); font-size: var(--fs-caption); }

/* ---------- Selected locations map ---------- */
.map { position: relative; }
.map svg { background: var(--sheet); }
.map-land { fill: var(--sheet-shade); stroke: var(--rule); stroke-width: 0.8; }
.map-borders { fill: none; stroke: var(--rule); stroke-width: 0.6; }
.map-dot { cursor: pointer; outline: none; }
.map-dot .hit { fill: transparent; }
.map-dot .pin { fill: var(--water); stroke: var(--sheet); stroke-width: 2.5; transform-box: fill-box; transform-origin: center; }
.map-dot.is-on .pin { fill: var(--ink); transform: scale(1.6); }
.map-dot:focus-visible .pin { stroke: var(--ink); stroke-width: 3; }
.map-tip {
  position: absolute; z-index: 2; max-width: 260px; padding: var(--s-1) var(--s-2); pointer-events: none;
  background: var(--sheet); border: 1px solid var(--ink); font-family: var(--instrument); font-size: var(--fs-caption); line-height: 1.4;
}
.map-tip b { display: block; font-weight: 600; font-size: var(--fs-ui); }
.map-tip span { display: block; color: var(--graphite); }
.map-info { font-family: var(--instrument); font-size: var(--fs-caption); color: var(--graphite); margin: var(--s-2) 0 0; }

/* ---------- Actions ---------- */
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; min-height: calc(var(--tap) + var(--s-1)); font-family: var(--instrument); font-size: var(--fs-ui); font-weight: 600; line-height: 1.25; text-decoration: none; border-radius: 4px; padding: var(--s-1) var(--s-3); border: 1px solid var(--ink); }
.btn--primary { background: var(--ink); color: var(--sheet); }
.btn--primary:hover { background: var(--graphite); border-color: var(--graphite); }
.btn--secondary { color: var(--ink); background: transparent; border-color: var(--graphite); }
.btn--secondary:hover { border-color: var(--ink); background: var(--sheet-shade); }

.note { font-family: var(--instrument); font-size: var(--fs-value); color: var(--graphite); background: var(--sheet-shade); padding: var(--s-2) var(--s-3); max-width: 68ch; }

.sister { margin: var(--s-4) 0 0; padding: var(--s-3); background: var(--sheet-shade); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2) var(--s-4); align-items: center; }
.sister p { margin: 0; max-width: 56ch; }
.sister strong { font-weight: 500; }

/* ---------- Footer ---------- */
.imprint { border-top: 2px solid var(--ink); margin-top: var(--s-5); }
.imprint__inner { max-width: 1320px; margin: 0 auto; padding: var(--s-3) var(--gutter) var(--s-4); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2) var(--s-4); font-family: var(--instrument); font-size: var(--fs-caption); color: var(--graphite); }
.imprint p { margin: 0; }

/* ---------- Motion: the borehole draws once ---------- */
.draw { stroke-dasharray: var(--len, 1000); stroke-dashoffset: var(--len, 1000); animation: draw 2.4s var(--ease) 0.4s forwards; }
.appear { opacity: 0; animation: appear 0.5s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .draw { animation: none; stroke-dashoffset: 0; }
  .appear { animation: none; opacity: 1; }
  .menu[open] { animation: none; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1000px) {
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .sheet > aside { grid-column: 1; }
  .margin-card { position: static; margin-top: var(--s-3); }
  .margin-card ol { display: none; }
  .gates { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: var(--s-3); }
  .gates li:nth-child(3n)::before { right: 0; }
}
@media (max-width: 820px) {
  .masthead__inner { align-items: center; flex-wrap: nowrap; padding-top: var(--s-1); padding-bottom: var(--s-1); }
  .wordmark small { display: none; }
  .nav { display: none; }
  .menu-btn { display: inline-flex; align-items: center; gap: var(--s-1); }
  .menu-btn__bars, .menu-btn__bars::before, .menu-btn__bars::after { display: block; width: 18px; height: 2px; background: var(--ink); position: relative; }
  .menu-btn__bars::before, .menu-btn__bars::after { content: ""; position: absolute; left: 0; }
  .menu-btn__bars::before { top: -6px; }
  .menu-btn__bars::after { top: 6px; }
}

/* ---------- Phone ---------- */
@media (max-width: 620px) {
  /* Fig. 1 and the map shrink to the screen width; labels and markers grow just enough to read. */
  .fig-scroll, .map svg { margin: 0 calc(-1 * var(--gutter)); width: calc(100% + 2 * var(--gutter)); }
  .fig-scroll text { font-size: 26px; }
  .fig-scroll .co text { font-size: 20px; }
  .fig-scroll .co circle { r: 15px; }
  .map-dot .pin { transform: scale(1.8); }
  .map-dot.is-on .pin { transform: scale(2.6); }
  /* Phones: sections are separated by space only; lines appear only between items of one list or table. */
  .hero { padding: var(--s-4) 0 0; border-bottom: 0; }
  .sec { padding: var(--s-5) 0 0; border-bottom: 0; }
  .margin-card { border-top: 0; margin-top: var(--s-5); }
  .steps > li:first-child { border-top: 0; }
  .steps > li:last-child { border-bottom: 0; }
  .steps > li { grid-template-columns: var(--s-4) minmax(0, 1fr); gap: var(--s-2); }
  .gates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gates li:nth-child(3n)::before { right: calc(-1 * var(--s-2)); }
  .gates li:nth-child(2n)::before { right: 0; }
  .sister { grid-template-columns: minmax(0, 1fr); }
  .btn { width: 100%; }
  /* Tables stack on phones: the row heading on top, its content full width below. Words never break. */
  table, tbody, tr, th, td, caption { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { padding: var(--s-2) 0; }
  tbody tr + tr { border-top: 1px solid var(--rule); }
  tbody th, tbody td { width: auto; padding: 0; border: 0; }
  tbody th { margin-bottom: var(--s-1); }
}

/* ---------- Print: every page is an A4 sheet ---------- */
/* ---------- Copy deterrent: no selection except contact and legal lines ---------- */
html { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.allow-select { -webkit-user-select: text; user-select: text; }
img, svg { -webkit-user-drag: none; }

/* ---------- Print: not available ---------- */
@media print {
  body > * { display: none !important; }
  body::before { content: "The Spektral-Q Technology Note is not available in print. Please read it online at spektral-q.com."; display: block; padding: 20mm; font-family: var(--instrument); font-size: 12pt; color: #000; }
}
