/* ============================================================
   Winchester — site
   The app's own screen: near-black panels, a cluster map, amber for
   a read, turquoise for a write. Dark by default, like the app; a
   light variant follows the visitor's system setting.
   ============================================================ */

/* No web font. The system stack is SF on the devices the app runs on,
   and a page about an app that collects nothing and connects to no
   server of its own should not make a request of its own to render
   itself. */

:root {
  /* From Sources/UI/Theme.swift. */
  --bg:         #0E0F12;   /* Theme.background */
  --panel:      #191A20;   /* Theme.panel */
  --panel-sink: #131418;
  --text:       #EBEBEB;   /* Theme.text */
  --dim:        #9A9A9E;   /* Theme.dim, lifted for body text on the page */
  --faint:      #74747A;
  --read:       #FFB247;   /* Theme.read — amber */
  --write:      #5CD1D1;   /* Theme.write — turquoise */
  --read-ink:   #FFB247;   /* amber used as text */
  --write-ink:  #5CD1D1;

  --rule:        rgba(255, 255, 255, 0.08);   /* Theme.stroke */
  --rule-strong: rgba(255, 255, 255, 0.18);

  /* Cluster map, from Sources/Model/ClusterPalette.swift. The map is a
     screen of the app, so it stays dark in both themes. */
  --map-bg:     #0E0F12;
  --c-free:     #292929;
  --c-reserved: #B8B8B8;
  --c-system:   #5C8CDB;
  --c-system-1: #4A70AF;   /* one piece: a fifth darker */
  --c-app:      #9E7ADB;
  --c-app-1:    #7E62AF;
  --c-doc:      #6BC285;
  --c-doc-1:    #569B6A;
  --c-archive:  #61999E;
  --c-churn:    #DB944D;
  --c-swap:     #D65C66;
  --c-dir:      #EBD161;

  --font-sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --font-round: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:  ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --fs-display: clamp(2.4rem, 6.4vw, 4.6rem);
  --fs-h1:      clamp(1.9rem, 3.6vw, 2.75rem);
  --fs-h2:      clamp(1.3rem, 2.2vw, 1.7rem);
  --fs-h3:      1.1rem;
  --fs-small:   0.9375rem;
  --fs-tiny:    0.8125rem;

  --col-label: 10rem;
  --gap-col:   3rem;
  --measure:   40rem;
  --wide:      64rem;

  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:         #F2F1EC;
    --panel:      #FFFFFF;
    --panel-sink: #E6E4DD;
    --text:       #16171B;
    --dim:        #55565D;
    --faint:      #7A7B82;
    --read-ink:   #9A5A00;   /* amber darkened to hold 4.5:1 on paper */
    --write-ink:  #16777A;
    --rule:        rgba(22, 23, 27, 0.12);
    --rule-strong: rgba(22, 23, 27, 0.26);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--write);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 20;
  background: var(--panel);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
}
.skip:focus { top: 0.75rem; }

.container {
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right));
}

@media (min-width: 40rem) {
  .container { padding-inline: clamp(1.25rem, 5vw, 3rem); }
}

/* ---------- header ---------- */

.masthead {
  border-bottom: 1px solid var(--rule-strong);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.masthead__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 0.9rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
}

.wordmark::before {
  /* The disk-activity LED of the pass screen. */
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--read);
  align-self: center;
}

.wordmark b { font-weight: inherit; color: var(--text); }
.wordmark span { color: var(--dim); font-weight: 500; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.4rem;
  font-size: var(--fs-small);
  color: var(--dim);
}

.nav a { text-decoration: none; }
.nav a:hover { color: var(--text); }
.nav a[aria-current='page'] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--read);
}

/* ---------- hero ---------- */

.hero { padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.5rem, 3vw, 2.25rem); }

.hero__icon {
  width: clamp(72px, 9vw, 104px);
  height: auto;
  border-radius: 22.37%;   /* the iOS squircle, near enough */
  margin-bottom: 1.75rem;
  box-shadow: 0 0 0 1px var(--rule-strong);
}

.hero h1 {
  font-family: var(--font-round);
  font-size: var(--fs-display);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin: 0 0 1.4rem;
  max-width: 17ch;
}

.hero p {
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  color: var(--dim);
  max-width: 46ch;
  margin: 0;
}

.hero .facts {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--dim);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  padding: 0;
  list-style: none;
}

.hero .facts li::before { content: '· '; color: var(--faint); }
.hero .facts li:first-child::before { content: ''; }

/* The App Store call to action: the site's own button, not Apple's badge —
   no image hotlinked, and it follows the light and dark themes. */
.hero .cta {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.cta__button {
  display: inline-flex;
  flex-direction: column;
  padding: 0.55rem 1.25rem 0.6rem;
  border-radius: 14px;   /* the app's panel radius */
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  line-height: 1.1;
  box-shadow: inset 0 -3px 0 var(--read);
}

.cta__button:hover { background: var(--dim); }

.cta__small { font-size: var(--fs-tiny); }

.cta__big {
  font-family: var(--font-round);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cta__note {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--dim);
}

/* ---------- the cluster map ---------- */

.volume {
  margin: 0 0 clamp(2.5rem, 6vw, 4rem);
  padding: 1rem;
  background: var(--map-bg);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;   /* the app's panel radius */
}

.volume__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.04em;
  color: #9A9A9E;   /* the map panel is dark in both themes */
}

.volume__head b { color: #EBEBEB; font-weight: 600; }

.volume__head .led {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.volume__head .led::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #FFB247;
}

.map { width: 100%; height: auto; }

.map rect      { fill: var(--c-free); }
.map .r        { fill: var(--c-reserved); }
.map .s        { fill: var(--c-system); }
.map .s1       { fill: var(--c-system-1); }
.map .a        { fill: var(--c-app); }
.map .a1       { fill: var(--c-app-1); }
.map .d        { fill: var(--c-doc); }
.map .d1       { fill: var(--c-doc-1); }
.map .z        { fill: var(--c-archive); }
.map .c        { fill: var(--c-churn); }
.map .w        { fill: var(--c-swap); }
.map .y        { fill: var(--c-dir); }
.map .tr       { fill: #FFB247; }   /* read trace */
.map .tw       { fill: #5CD1D1; }   /* write trace */

/* A few blocks catch the head as it passes: an amber or turquoise
   overlay that lights up, then fades in about a third of a second,
   like the trace in the app. Decorative only — the static trace above
   says the same thing — and it is not drawn at all under Reduce Motion. */
.map .fr, .map .fw {
  opacity: 0;
  animation: flash 6s linear infinite;
}
.map .fr { fill: #FFB247; }
.map .fw { fill: #5CD1D1; }

@keyframes flash {
  0%, 1%  { opacity: 1; }
  6.5%    { opacity: 0; }
  100%    { opacity: 0; }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-tiny);
  color: #9A9A9E;
}

.legend li { display: inline-flex; align-items: center; gap: 0.45rem; }

.swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 2px;
  flex: none;
}

.sw-read   { background: #FFB247; }
.sw-write  { background: #5CD1D1; }
.sw-free   { background: var(--c-free); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.sw-system { background: linear-gradient(90deg, var(--c-system-1) 50%, var(--c-system) 50%); }
.sw-app    { background: linear-gradient(90deg, var(--c-app-1) 50%, var(--c-app) 50%); }
.sw-doc    { background: linear-gradient(90deg, var(--c-doc-1) 50%, var(--c-doc) 50%); }
.sw-dir    { background: var(--c-dir); }
.sw-churn  { background: var(--c-churn); }
.sw-archive { background: var(--c-archive); }
.sw-swap   { background: var(--c-swap); }
.sw-fat    { background: var(--c-reserved); }

/* ---------- sheet: label column + content ---------- */

/* An anchor must not land under the sticky header. */
[id] { scroll-margin-top: 5.5rem; }

.sheet {
  border-top: 1px solid var(--rule);
  padding-block: clamp(2.25rem, 5vw, 3.5rem);
}

.sheet__grid {
  display: grid;
  grid-template-columns: var(--col-label) minmax(0, 1fr);
  gap: 0 var(--gap-col);
  align-items: start;
}

.sheet .sheet__label {
  /* Beats `.sheet h2`: the label is an h2 too, for the outline. */
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--read-ink);
  line-height: 1.4;
  max-width: none;
  margin: 0;
  padding-top: 0.45rem;
}

.sheet__body { max-width: var(--measure); min-width: 0; }
.sheet__body > :first-child { margin-top: 0; }
.sheet__body > :last-child { margin-bottom: 0; }

.sheet h2 {
  font-family: var(--font-round);
  font-size: var(--fs-h2);
  font-weight: 650;
  line-height: 1.18;
  margin: 0 0 1rem;
  max-width: 24ch;
}

.sheet h3 {
  font-size: var(--fs-h3);
  font-weight: 650;
  margin: 2rem 0 0.5rem;
}

.sheet p { margin: 0 0 1rem; }
.sheet ul, .sheet ol { margin: 0 0 1rem; padding-left: 1.2rem; }
.sheet li { margin-bottom: 0.5rem; }
.sheet li::marker { color: var(--faint); }

.ui {
  /* A label exactly as the app shows it. */
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- the three sounds, the steps of a chain ---------- */

.steps { list-style: none; margin: 0 0 1rem; padding: 0; counter-reset: step; }

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0 1rem;
  padding-block: 0.9rem;
  border-top: 1px solid var(--rule);
  margin: 0;
}

.steps li:first-child { border-top: 0; padding-top: 0; }

.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--faint);
  padding-top: 0.1rem;
}

.steps__name { grid-column: 2; font-weight: 650; margin-bottom: 0.15rem; }
.steps__note { grid-column: 2; color: var(--dim); font-size: var(--fs-small); }

/* ---------- tables ---------- */

.scroll-x {
  overflow-x: auto;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

.scroll-x .spec { margin-bottom: 0; min-width: 30rem; }

.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  margin-bottom: 1rem;
}

.spec caption {
  text-align: left;
  color: var(--dim);
  padding-bottom: 0.6rem;
}

.spec th, .spec td {
  text-align: left;
  padding: 0.55rem 1rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.spec thead th {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.spec tbody th { font-weight: 650; }
.spec td:last-child { padding-right: 0; }
.spec .num { font-family: var(--font-mono); font-size: 0.875rem; white-space: nowrap; }
.spec .origin { color: var(--dim); white-space: nowrap; }

/* ---------- contact list ---------- */

.contact { margin: 0; }
.contact dt { font-size: var(--fs-tiny); color: var(--dim); margin-bottom: 0.15rem; }
.contact dd {
  margin: 0 0 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  word-break: break-word;
}

/* ---------- document header for support / privacy ---------- */

.doc-head { padding-block: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 3vw, 2.25rem); }

.doc-head h1 {
  font-family: var(--font-round);
  font-size: var(--fs-h1);
  font-weight: 700;
  line-height: 1.05;
  margin: 0 0 0.75rem;
  max-width: 20ch;
}

.doc-head p { margin: 0; color: var(--dim); max-width: 52ch; }

.doc-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--faint);
  margin: 0 0 1.25rem;
}

.doc-head .doc-meta { color: var(--dim); margin-bottom: 1.25rem; }
.doc-head .doc-meta--after { margin: 1.5rem 0 0; max-width: 60ch; }

/* ---------- callout ---------- */

.note {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--write);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.25rem;
  margin: 0 0 1rem;
  font-size: var(--fs-small);
}

.note p { margin: 0; }
.note p + p { margin-top: 0.6rem; }

/* ---------- on this page ---------- */

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--dim);
}

.toc li { margin: 0; }

code { font-family: var(--font-mono); font-size: 0.875em; }

/* ---------- footer ---------- */

.footer {
  margin-top: auto;
  border-top: 1px solid var(--rule-strong);
  padding-block: 2rem max(3rem, env(safe-area-inset-bottom));
  font-size: var(--fs-tiny);
  color: var(--dim);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
}

.footer nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.footer p { margin: 0.75rem 0 0; max-width: 60ch; color: var(--faint); }
.footer .footer__apps { color: var(--dim); }

/* ---------- responsive ---------- */

@media (max-width: 46rem) {
  .sheet__grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sheet .sheet__label {
    padding-top: 0;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--rule);
  }
  .hero h1 { max-width: none; }
  .volume { padding: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .map .fr, .map .fw { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .swatch { forced-color-adjust: none; }
}

@media print {
  .masthead, .footer nav, .skip { display: none; }
  html { background: #fff; color: #000; font-size: 11pt; }
}
