@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* A blueprint, drawn in pencil: deep blue that darkens toward the edges, a faint paper tooth, a drafting grid. */
:root {
  --blue-deep: #0F325D;
  --blue: #1A4880;
  --blue-light: #235894;
  --ink: #F2F6FB;
  --ink-2: #C9D8EC;
  --ink-3: #9FB7D6;
  --lead: rgba(232, 241, 255, 0.5);
  --lead-faint: rgba(232, 241, 255, 0.28);
  --grid-minor: rgba(232, 241, 255, 0.05);
  --grid-major: rgba(232, 241, 255, 0.11);
  --sheet-line: rgba(232, 241, 255, 0.16);
  --lamp: #F7CD45;
  --note: #FCE9B0;
  --note-line: rgba(252, 233, 176, 0.7);
  --river: #4E8FDF;
  --lr: clamp(150px, 18vw, 240px);   /* how far the lamp's light reaches */
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { overflow-x: clip; }

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow-x: clip;
  color: var(--ink);
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  background-color: var(--blue);
  background-image:
    url("/paper-grain.png"),
    radial-gradient(130% 95% at 50% 42%, transparent 52%, rgba(6, 20, 42, 0.55)),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px),
    radial-gradient(90% 70% at 50% 38%, var(--blue-light), var(--blue) 55%, var(--blue-deep));
  background-size: 160px 160px, auto, 100px 100px, 100px 100px, 20px 20px, 20px 20px, auto;
  background-position: 0 0, center, center, center, center, center, center;
  background-attachment: fixed;
}

/* The sheet: a ruled border with zone marks, and a title block in the corner on wide screens. */
.sheet { position: fixed; inset: 8px; z-index: 0; border: 1px solid var(--sheet-line); pointer-events: none; }
.zones, .title-block { display: none; }
.motes { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow-x: clip;   /* the drawing may run past the edges on a phone, never the page */
  justify-items: center;
  align-content: center;
  gap: clamp(8px, 1.8vh, 20px);
  padding: 28px 20px 4px;
  text-align: center;
}

.lockup { width: min(330px, 70vw); height: auto; }

.plate { position: relative; width: clamp(600px, 62vw, 820px); justify-self: center; }
.drawing { display: block; width: 100%; height: auto; overflow: visible; }
.ink { fill: none; stroke: var(--lead); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ink.faint { stroke: var(--lead-faint); }
.gear { transform-box: fill-box; transform-origin: center; }

.face { fill: rgba(12, 38, 72, 0.38); stroke: var(--ink); stroke-width: 1.8; }
.tick { stroke: var(--ink-3); stroke-width: 1.2; stroke-linecap: round; }
.tick.hour { stroke: var(--ink); stroke-width: 2.6; }
.hand { transform-box: view-box; transform-origin: 120px 120px; }
.hand line { stroke-linecap: round; }
.hour line { stroke: var(--ink); stroke-width: 6.5; }
.minute line { stroke: var(--ink); stroke-width: 4.2; }
.second line { stroke: var(--lamp); stroke-width: 1.7; }
.second circle { fill: var(--lamp); }
.cap { fill: var(--river); stroke: var(--ink); stroke-width: 1.2; }
.pin { fill: var(--blue-deep); }

/* The construction circle stops eight seconds short of closing. The pencil rests in the gap. */
.ink.d1 { stroke-dasharray: 1; stroke-dashoffset: 0.1333; }
.tip-core { fill: #FFF4CF; }
.chime { fill: none; stroke: var(--lamp); stroke-width: 1.4; opacity: 0; transform-box: fill-box; transform-origin: center; }

/* The dial can be wound. */
.winder {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 21%;
  aspect-ratio: 1;
  translate: -50% -50%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.45s ease;
}
.winder:hover { box-shadow: 0 0 0 1.5px rgba(247, 205, 69, 0.5), 0 0 40px 6px rgba(247, 205, 69, 0.14); }
.winder:focus-visible { outline: 2px solid var(--lamp); outline-offset: 6px; }
.winder[aria-busy="true"] { cursor: progress; box-shadow: none; }

.line {
  margin: 0;
  max-width: 22ch;
  font-size: clamp(23px, 3.6vw, 36px);
  font-weight: 520;
  line-height: 1.18;
  letter-spacing: -0.012em;
  text-wrap: balance;
  text-shadow: 0 1px 0 rgba(6, 20, 42, 0.35);
}
.dots i { font-style: normal; }

.crossing { position: relative; width: min(560px, 86vw); margin-top: -10px; }
.ford { display: block; width: 100%; height: auto; }
.whisper {
  position: absolute;
  inset: -2px 0 auto;
  margin: 0;
  font: 13px/1.4 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lamp);
  text-shadow: 0 0 18px rgba(247, 205, 69, 0.5);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  pointer-events: none;
}
.whisper.on { opacity: 1; transform: none; }
.nowrap { white-space: nowrap; }

/* Notes pencilled onto the sheet that show only under the lamp. */
.secret {
  --mx: -9999px;
  --my: -9999px;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  visibility: hidden;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle var(--lr) at var(--mx) var(--my), #000, rgba(0, 0, 0, 0.9) 35%, transparent);
  mask-image: radial-gradient(circle var(--lr) at var(--mx) var(--my), #000, rgba(0, 0, 0, 0.9) 35%, transparent);
}
@supports ((mask-image: none) or (-webkit-mask-image: none)) {
  .lit .secret { visibility: visible; }
}
.callout { fill: none; stroke: var(--note-line); stroke-width: 1.3; stroke-linecap: round; }
.callout circle { fill: var(--note); stroke: none; }
.callout text { fill: var(--note); stroke: none; font-family: var(--mono); font-size: 16px; letter-spacing: 0.08em; }
.ford-note text { font-size: 26px; }

.margin-notes.secret { position: fixed; z-index: 1; display: none; }
.note {
  position: absolute;
  margin: 0;
  font: 12px/1.6 var(--mono);
  letter-spacing: 0.14em;
  text-align: left;
  color: var(--note);
  text-shadow: 0 0 14px rgba(247, 205, 69, 0.28);
}
.n1 { top: 13vh; left: 4.5vw; rotate: -2deg; }
.n2 { top: 56vh; left: 6vw; rotate: 1.5deg; }
.n3 { top: 19vh; right: 6vw; rotate: 2deg; }
.n4 { top: 58vh; right: 7vw; rotate: -1.5deg; }
.n5 { bottom: 12vh; left: 4.5vw; rotate: -1deg; }
.keyhole { display: block; width: 20px; height: 30px; margin-bottom: 8px; fill: none; stroke: var(--note-line); stroke-width: 1.4; stroke-linejoin: round; }

/* The lamp: a warm pool of light carried over the sheet. */
.lamp {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  display: none;
  width: calc(var(--lr) * 3);
  height: calc(var(--lr) * 3);
  margin: calc(var(--lr) * -1.5) 0 0 calc(var(--lr) * -1.5);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 228, 168, 0.22), rgba(255, 214, 130, 0.09) 42%, transparent);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 1.6s ease;
  pointer-events: none;
  will-change: transform;
}
.lit .lamp { display: block; }
.lamp.on { opacity: 1; }

.foot {
  position: relative;
  z-index: 1;
  padding: 10px 24px 20px;
  text-align: center;
  font: 12px/1.6 var(--mono);
  letter-spacing: 0.05em;
  color: var(--ink-2);
}
.foot a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(232, 241, 255, 0.35); }
.foot a:hover { text-decoration-color: var(--lamp); }
.foot a:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 2px; }

.home-mark { display: block; line-height: 0; }
.home {
  font: 14px/1.4 var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(232, 241, 255, 0.35);
}
.home:hover { color: var(--ink); text-decoration-color: var(--lamp); }
.home:focus-visible, .home-mark:focus-visible { outline: 2px solid var(--lamp); outline-offset: 6px; border-radius: 2px; }

@media (min-width: 900px) {
  .sheet { inset: 18px; }
  .zones { position: absolute; display: flex; justify-content: space-around; align-items: center; font: 9px/1 var(--mono); letter-spacing: 0.1em; color: var(--ink-3); opacity: 0.6; }
  .zones i { font-style: normal; }
  .zones.top, .zones.bottom { left: 0; right: 0; height: 18px; }
  .zones.top { top: -18px; }
  .zones.bottom { bottom: -18px; }
  .zones.side, .zones.right { top: 0; bottom: 0; width: 18px; flex-direction: column; }
  .zones.side { left: -18px; }
  .zones.right { right: -18px; }
  .foot { padding-bottom: 26px; }
}
@media (min-width: 1000px) {
  .margin-notes.secret { display: block; }
}
/* On a phone held upright there is room above the logo and below the bridge for two of the notes. */
@media (max-width: 999px) and (min-height: 700px) {
  .margin-notes.secret { display: block; }
  .n2, .n3, .n4 { display: none; }
  .n1 { top: 4.5vh; left: 7vw; }
  .n5 { bottom: 14vh; left: auto; right: 7vw; text-align: right; }
}
@media (min-width: 1180px) and (min-height: 700px) {
  .title-block {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, auto);
    border-top: 1px solid var(--sheet-line);
    border-left: 1px solid var(--sheet-line);
    font: 10px/1.3 var(--mono);
    letter-spacing: 0.1em;
    color: var(--ink-2);
    text-align: left;
    pointer-events: none;
  }
  .title-block > div { padding: 5px 12px 6px; border-right: 1px solid var(--sheet-line); border-bottom: 1px solid var(--sheet-line); }
  .title-block b { display: block; font-weight: 400; font-size: 8px; color: var(--ink-3); }
  .title-block .tb-name { grid-column: span 2; align-self: stretch; display: flex; align-items: center; font: 650 13px/1 "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif; letter-spacing: 0.26em; color: var(--ink); }
}

@media (prefers-reduced-motion: no-preference) {
  /* The drawing sketches itself in, as if drafted while you watch. */
  .ink { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draft 2.2s cubic-bezier(0.45, 0.05, 0.35, 1) forwards; }
  .d1 { animation-delay: 0.1s; }
  .d2 { animation-delay: 0.4s; }
  .d3 { animation-delay: 0.75s; }
  .d4 { animation-delay: 1.05s; }
  .d5 { animation-delay: 1.35s; }
  .ink.d1 { stroke-dashoffset: 1; animation-name: draft-open; animation-duration: 2.6s; }
  @keyframes draft { to { stroke-dashoffset: 0; } }
  @keyframes draft-open { to { stroke-dashoffset: 0.1333; } }
  /* A mechanical tick: the second hand overshoots a hair and settles; the escapement wheel ticks with it. */
  .second { transition: transform 300ms cubic-bezier(0.34, 1.9, 0.5, 1); }
  .gear { transition: transform 1s linear; }
  .gear.escapement { transition: transform 320ms cubic-bezier(0.34, 1.7, 0.5, 1); }
  /* The pencil glows, slowly; faster while it strains to close the circle. */
  .tip-halo { transform-box: fill-box; transform-origin: center; animation: breathe 3.4s ease-in-out infinite; }
  .tip.strain .tip-halo { animation-duration: 0.45s; }
  @keyframes breathe { 0%, 100% { opacity: 0.7; transform: scale(0.88); } 50% { opacity: 1; transform: scale(1.15); } }
  /* On the minute, a ring passes over the dial. */
  .chime.ring { animation: chime 1.9s cubic-bezier(0.2, 0.6, 0.3, 1); }
  @keyframes chime { from { opacity: 0.6; transform: scale(1); } to { opacity: 0; transform: scale(1.6); } }
  /* The dots wait their turn. */
  .dots i { animation: waiting 2.8s ease-in-out infinite; }
  .dots i:nth-child(2) { animation-delay: 0.28s; }
  .dots i:nth-child(3) { animation-delay: 0.56s; }
  @keyframes waiting { 0%, 55%, 100% { color: var(--ink); text-shadow: 0 1px 0 rgba(6, 20, 42, 0.35); } 22% { color: var(--lamp); text-shadow: 0 0 16px rgba(247, 205, 69, 0.65); } }
}
