/* ATLAS · ozan.ing — plate viewer */
:root {
  --bg: #050608;
  --ink: #f3f1eb;
  --ink-2: rgba(243, 241, 235, 0.78);
  --muted: rgba(243, 241, 235, 0.52);
  --faint: rgba(243, 241, 235, 0.30);
  --hair: rgba(243, 241, 235, 0.15);
  --brass: #d9a441;
  --brass-hi: #f5b942;
  --panel: rgba(6, 7, 10, 0.86);
  --serif: 'Fraunces', Georgia, serif;
  --mono: 'Chivo Mono', ui-monospace, Menlo, monospace;
  --sans: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --math: 'STIX Two Text', 'Cambria Math', 'Times New Roman', serif;
  --pad-x: 34px;
  --pad-y: 24px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0; }

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#gl.dragging { cursor: grabbing; }

/* Registration marks: the plate's printed border */
.frame {
  position: fixed;
  inset: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
  pointer-events: none;
  z-index: 2;
}
.frame i {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--faint);
  border-style: solid;
  border-width: 0;
}
.frame i:nth-child(1) { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.frame i:nth-child(2) { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.frame i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.frame i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

/* Top bar */
.top {
  position: fixed;
  top: calc(var(--pad-y) + var(--safe-t));
  left: calc(var(--pad-x) + var(--safe-l));
  right: calc(var(--pad-x) + var(--safe-r));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  z-index: 6;
}
.crumbs-col { display: flex; flex-direction: column; gap: 6px; }
.crumbs { display: flex; align-items: center; gap: 10px; }
.brand, .crumb {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-decoration: none;
  color: var(--ink);
  padding-bottom: 1px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.crumb { color: var(--brass); }
.brand:hover, .brand:focus-visible, .crumb:hover, .crumb:focus-visible {
  color: var(--brass-hi);
  border-bottom-color: rgba(245, 185, 66, 0.55);
  outline: none;
}
.sep { font-family: var(--mono); font-size: 11px; color: var(--hair); }
.tagline {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.actions { display: flex; gap: 8px; align-items: center; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn {
  appearance: none;
  white-space: nowrap;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  padding: 8px 13px;
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--hair);
  color: var(--muted);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.btn:hover { color: var(--ink); border-color: rgba(243, 241, 235, 0.45); }
.btn:focus-visible, .step:focus-visible, .scale:focus-visible, .card:focus-visible {
  outline: 1px solid var(--brass-hi);
  outline-offset: 3px;
}
.btn[aria-expanded="true"] { color: var(--brass-hi); border-color: rgba(245, 185, 66, 0.55); }

/* Plate legend (künye) */
.plate {
  position: fixed;
  left: calc(var(--pad-x) + var(--safe-l));
  bottom: calc(118px + var(--safe-b));
  width: min(440px, 36vw);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.plate.swap { opacity: 0; transform: translateY(6px); }
.plate a, .plate button { pointer-events: auto; }
/* the legend's text can be selected and copied; the figure stays draggable around it */
.plate .pl-name, .plate .pl-formula, .plate .pl-params, .plate .pl-by, .plate .pl-note {
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  width: fit-content;
  max-width: 100%;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.plate-head {
  display: flex;
  white-space: nowrap;
  align-items: baseline;
  gap: 14px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  letter-spacing: 0.18em;
}
.pl-no { color: var(--ink); }
.pl-no .of { color: var(--muted); }
.pl-fam { color: var(--brass); }
.pl-fam::before {
  content: '';
  display: inline-block;
  width: 22px;
  height: 1px;
  margin: 0 12px 3px 0;
  background: var(--hair);
  vertical-align: middle;
}
.pl-day {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.pl-day b { color: var(--brass-hi); font-weight: 400; }
.pl-name {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 0, "WONK" 0;
  font-weight: 400;
  font-size: clamp(34px, 3.9vw, 56px);
  line-height: 0.98;
  letter-spacing: -0.02em;
  color: #fbfaf7;
  text-shadow: 0 8px 34px rgba(0, 0, 0, 0.9);
  text-wrap: balance;
  margin-top: 2px;
}
.pl-name.long { font-size: clamp(30px, 3vw, 42px); }
.pl-formula {
  font-family: var(--math);
  font-size: 18px;
  line-height: 1.42;
  color: var(--ink);
  border-left: 1px solid var(--brass);
  padding: 1px 0 1px 12px;
  margin-top: 4px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
  overflow-wrap: anywhere;
}
.pl-formula.long { font-size: 15px; }
.pl-formula.xlong { font-size: 14px; }
.pl-params {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--muted);
  padding-left: 13px;
}
.pl-by {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-top: 4px;
}
.pl-note {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 400px;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.95);
}

/* Instrument readout */
.readout {
  position: fixed;
  right: calc(var(--pad-x) + var(--safe-r));
  bottom: calc(122px + var(--safe-b));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  pointer-events: none;
}

/* Dock: prev · scale · next */
.dock {
  position: fixed;
  left: calc(var(--pad-x) + var(--safe-l));
  right: calc(var(--pad-x) + var(--safe-r));
  bottom: calc(22px + var(--safe-b));
  max-width: 1180px;
  margin: 0 auto;
  height: 58px;
  display: flex;
  gap: 8px;
  z-index: 6;
}
.step {
  appearance: none;
  flex: none;
  width: 52px;
  background: var(--panel);
  border: 1px solid var(--hair);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 15px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.step:hover { color: var(--brass-hi); border-color: rgba(245, 185, 66, 0.5); }
.scale {
  position: relative;
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--hair);
  cursor: ew-resize;
  touch-action: none;
  overflow: hidden;
}
.scale-fams, .scale-ticks { position: absolute; inset: 0; pointer-events: none; }
.scale-fam {
  position: absolute;
  top: 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
  white-space: nowrap;
  transform: translateX(-1px);
}
.scale-fam .n { color: var(--brass); margin-right: 6px; }
.scale-fam.on { color: var(--ink); }
.scale-tick {
  position: absolute;
  bottom: 8px;
  width: 1px;
  height: 7px;
  background: rgba(243, 241, 235, 0.22);
}
.scale-tick.major { height: 30px; background: rgba(243, 241, 235, 0.34); }
.scale-needle {
  position: absolute;
  top: 24px;
  bottom: 5px;
  width: 2px;
  margin-left: -1px;
  background: var(--brass-hi);
  box-shadow: 0 0 12px rgba(245, 185, 66, 0.7);
  transition: left 0.5s cubic-bezier(0.22, 0.8, 0.24, 1);
  pointer-events: none;
}
.scale-needle::after {
  content: '';
  position: absolute;
  top: -7px;
  left: -4px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--brass-hi);
}
.scale-hover {
  position: absolute;
  top: 6px;
  padding: 0 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--brass-hi);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* Index of plates */
.index {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 0 calc(var(--pad-x) + var(--safe-r)) calc(48px + var(--safe-b)) calc(var(--pad-x) + var(--safe-l));
}
.index-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: calc(var(--pad-y) + var(--safe-t)) 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--hair);
}
.index-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -0.01em;
}
.index-title .count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-left: 14px;
  vertical-align: middle;
}
.fam-section { padding-top: 30px; }
.fam-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.fam-head .n { color: var(--brass); }
.fam-head .c { color: var(--muted); }
.fam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.card {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: 1px solid var(--hair);
  padding: 8px 8px 10px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.card:hover { border-color: rgba(243, 241, 235, 0.45); }
.card.current { border-color: var(--brass); }
.card canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #020304;
}
.card .no {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.card.current .no { color: var(--brass-hi); }
.card .nm {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.15;
  color: var(--ink);
}

/* No-WebGL fallback */
.fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  overflow-y: auto;
  padding: calc(44px + var(--safe-t)) 28px calc(44px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.fallback.is-static { display: flex; }
/* text-only atlas: the top bar (with the language button) stays above the list */
body.no-gl .top { z-index: 31; }
body.no-gl #index-btn { display: none; }
/* a lost context leaves the browser's blank canvas placeholder behind the bar */
body.no-gl #gl { visibility: hidden; }
body.no-gl .fallback {
  top: calc(84px + var(--safe-t));
  padding: 20px calc(var(--pad-x) + var(--safe-r)) calc(44px + var(--safe-b)) calc(var(--pad-x) + var(--safe-l));
  border-top: 1px solid var(--hair);
}
body.no-gl .fallback-kicker { display: none; }
.fallback-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em; color: var(--muted); }
.fallback-kicker a { color: var(--ink); text-decoration: none; }
.fallback-title { font-family: var(--serif); font-weight: 400; font-size: 44px; }
.fallback-msg { color: var(--ink-2); max-width: 560px; line-height: 1.5; }
.fallback-list { list-style: none; display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.fallback-list li { border-top: 1px solid var(--hair); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.fallback-list .fn { font-family: var(--serif); font-size: 20px; }
.fallback-list .ff { font-family: var(--math); font-size: 16px; }
.fallback-list .fm { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; color: var(--muted); }

/* Phone */
@media (max-width: 760px) {
  :root { --pad-x: 16px; --pad-y: 16px; }
  .frame { display: none; }
  .top { flex-wrap: wrap; gap: 10px 12px; }
  .actions { gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .tagline { font-size: 10.5px; }
  .brand, .crumb { font-size: 11px; letter-spacing: 0.2em; }
  .btn { padding: 7px 9px; font-size: 9.5px; letter-spacing: 0.11em; }
  .plate {
    width: auto;
    right: calc(var(--pad-x) + var(--safe-r));
    bottom: calc(86px + var(--safe-b));
    gap: 7px;
  }
  .pl-name, .pl-name.long { font-size: clamp(28px, 8vw, 36px); }
  .plate-head { flex-wrap: wrap; gap: 4px 12px; font-size: 9.5px; letter-spacing: 0.14em; }
  .pl-no { white-space: nowrap; }
  .pl-fam::before { display: none; }
  .pl-formula { font-size: 15.5px; }
  .pl-formula.long { font-size: 13px; }
  .pl-formula.xlong { font-size: 12px; line-height: 1.36; }
  .pl-params { font-size: 9.5px; }
  .pl-by { font-size: 9.5px; }
  .pl-note { font-size: 13px; line-height: 1.45; }
  .readout { display: none; }
  .dock { bottom: calc(14px + var(--safe-b)); height: 54px; gap: 6px; }
  .step { width: 46px; }
  .scale-fam { font-size: 8.5px; letter-spacing: 0.08em; }
  .scale-fam .t { display: none; }
  .fam-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .card .nm { font-size: 13px; }
}

@media (max-height: 560px) and (min-width: 761px) {
  .pl-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .plate, .scale-needle { transition: none; }
}
