/* ------------------------------------------------------------------
   Kedge Line — base
   Fonts, tokens, page shell, accessibility primitives.
   ------------------------------------------------------------------ */

@font-face {
  font-family: "Fell";
  src: url("/assets/fonts/im-fell-english-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fell";
  src: url("/assets/fonts/im-fell-english-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Fell SC";
  src: url("/assets/fonts/im-fell-english-sc-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --parch-1: #e9dcc0;
  --parch-2: #ddcba6;
  --parch-3: #cbb68d;
  --ink: #2b2318;
  --ink-soft: #4a3d2c;
  --ink-faint: #6b5a42;
  --oxblood: #79302a;
  --verdigris: #3c5a4c;
  --water: #8d9a84;

  /* How far the sheet is inset from the viewport. Zero means full bleed. */
  --sheet-inset: 0px;
  --desk: #2c251c;

  --display: "Fell", "Iowan Old Style", Palatino, Georgia, serif;
  --display-sc: "Fell SC", "Iowan Old Style", Palatino, Georgia, serif;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
  background: #12100d;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.55;
  overflow: hidden;
  background: #12100d;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-boot="loading"] .chart-shell,
body[data-boot="loading"] .masthead {
  opacity: 0;
}

.chart-shell {
  position: fixed;
  inset: 0;
  opacity: 1;
  transition: opacity 600ms var(--ease);
}

/* --- sheet on a desk --------------------------------------------- */
/* Opt in with ?sheet=desk. The chart is cropped to a trimmed sheet and the
   desk shows around it; the cast shadow lives on the still container, never
   on a layer that pans. */

body[data-sheet="desk"] {
  --sheet-inset: clamp(18px, 3.4vmin, 46px);
}

body[data-sheet="desk"] .chart-shell {
  background:
    radial-gradient(120% 130% at 26% 6%, #4c4033 0%, #322a20 46%, #241e17 100%);
}

/* The cast shadow lives on a still pseudo-element behind the sheet, so the
   container that holds the panning canvas never repaints it. */
body[data-sheet="desk"] .chart-shell::before {
  content: "";
  position: absolute;
  inset: var(--sheet-inset);
  z-index: 0;
  pointer-events: none;
  box-shadow:
    0 0 0 1px rgba(28, 21, 13, 0.7),
    0 34px 80px -26px rgba(8, 5, 2, 0.85),
    0 8px 22px rgba(8, 5, 2, 0.45);
}

body[data-sheet="desk"] .chart {
  inset: var(--sheet-inset);
  z-index: 1;
}

body[data-sheet="desk"] .chart::after {
  inset: 0;
  border-color: rgba(43, 35, 24, 0.55);
  box-shadow:
    inset 0 0 0 5px rgba(255, 250, 236, 0.1),
    inset 0 0 0 6px rgba(43, 35, 24, 0.18),
    inset 0 0 54px rgba(86, 64, 36, 0.34);
}

body[data-sheet="desk"] .masthead {
  top: calc(var(--sheet-inset) + clamp(10px, 1.4vh, 20px));
  left: calc(var(--sheet-inset) + clamp(12px, 1.4vw, 22px));
}

body[data-sheet="desk"] .instruments {
  top: calc(var(--sheet-inset) + clamp(8px, 1.2vh, 16px));
  right: calc(var(--sheet-inset) + clamp(10px, 1.4vw, 20px));
}

/* --- masthead ---------------------------------------------------- */

.masthead {
  position: fixed;
  top: clamp(14px, 2.2vh, 26px);
  left: clamp(14px, 2vw, 30px);
  z-index: 30;
  display: flex;
  align-items: baseline;
  gap: 14px;
  pointer-events: none;
  /* a paper halo keeps the wordmark legible over coast and sea alike */
  text-shadow:
    0 0 9px rgba(243, 232, 208, 0.95),
    0 0 20px rgba(243, 232, 208, 0.7),
    0 1px 0 rgba(242, 230, 205, 0.55);
}

.wordmark {
  margin: 0;
  font-family: var(--display-sc);
  font-size: clamp(15px, 1.35vw, 19px);
  letter-spacing: 0.42em;
  color: var(--ink);
}

.tagline {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(11px, 0.95vw, 14px);
  color: var(--ink-faint);
}

/* --- accessibility ----------------------------------------------- */

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: #f2e7d0;
  font-family: var(--display-sc);
  letter-spacing: 0.14em;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 180ms var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.status {
  position: fixed;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:where(button, a, [tabindex]):focus-visible {
  outline: 2px solid var(--oxblood);
  outline-offset: 3px;
}

.fallback {
  max-width: 62ch;
  margin: 0 auto;
  padding: 12vh 24px;
  color: var(--parch-1);
  font-family: var(--display);
  font-size: 1.1rem;
}

.fallback a {
  color: #d8b48f;
}

@media (prefers-reduced-motion: reduce) {
  .chart-shell,
  .skip-link {
    transition: none;
  }
}
