@font-face {
  font-family: "Alpha Lyrae";
  src: url("fonts/alpha-lyrae-medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DM Mono";
  src: url("fonts/dm-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DM Mono";
  src: url("fonts/dm-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* a viewfinder is dark: warm, film-like blacks and paper whites */
  --bg: oklch(0.16 0.006 60);
  --ink: oklch(0.95 0.008 80);
  --ink-2: oklch(0.78 0.01 75);
  --ink-3: oklch(0.67 0.012 70);
  --line: oklch(0.95 0.008 80 / 0.38);
  --signal: oklch(0.66 0.2 29);

  --gutter: clamp(16px, 3.6vw, 36px);
  --display: "Alpha Lyrae", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
}

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

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overflow-x: clip;
}

::selection { background: var(--signal); color: var(--bg); }

a { color: inherit; }

:focus-visible {
  outline: 1.5px solid var(--signal);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- viewfinder ---------- */

.vf {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overflow: clip;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-columns: minmax(0, 1fr);
  padding:
    max(var(--gutter), env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(var(--gutter), env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 0 solid var(--line);
  pointer-events: none;
}
.corner.tl { top: calc(var(--gutter) / 2); left: calc(var(--gutter) / 2); border-top-width: 1px; border-left-width: 1px; }
.corner.tr { top: calc(var(--gutter) / 2); right: calc(var(--gutter) / 2); border-top-width: 1px; border-right-width: 1px; }
.corner.bl { bottom: calc(var(--gutter) / 2); left: calc(var(--gutter) / 2); border-bottom-width: 1px; border-left-width: 1px; }
.corner.br { bottom: calc(var(--gutter) / 2); right: calc(var(--gutter) / 2); border-bottom-width: 1px; border-right-width: 1px; }

/* ---------- hud ---------- */

.hud {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}
.hud p { margin: 0; }

.wordmark {
  font-family: var(--display);
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.requested {
  display: flex;
  gap: 0.75em;
  min-width: 0;
  max-width: 60%;
}
.requested .value {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-bottom {
  margin-top: clamp(1.25rem, 3vh, 2rem);
  align-items: center;
}

.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  font-variant-numeric: tabular-nums;
}
.readout .file { color: var(--ink-2); }

.hint {
  margin-left: auto !important;
  transition: opacity 400ms ease;
}
.hint.gone { opacity: 0; }

.lang { display: flex; gap: 0.25rem; font-size: 0.8125rem; }
.lang button {
  font: inherit;
  color: var(--ink-3);
  background: none;
  border: 0;
  padding: 0.35rem 0.4rem;
  cursor: pointer;
  border-radius: 2px;
}
.lang button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

/* ---------- the subject that never comes into focus ---------- */

.subject {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(9rem, 38vh, 30rem);
  overflow: visible;
}

.num {
  grid-area: 1 / 1;
  font-family: var(--display);
  font-size: clamp(9rem, min(42vw, 50dvh), 36rem);
  line-height: 0.8;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  padding: 0.12em 0.08em 0.02em;
}

.soft {
  color: oklch(0.86 0.01 75 / 0.55);
  filter: blur(var(--blur, 0.032em));
}

.sharp {
  color: var(--ink);
  -webkit-mask-image: radial-gradient(circle 0px at 50% 50%, #000 55%, transparent 100%);
          mask-image: radial-gradient(circle 0px at 50% 50%, #000 55%, transparent 100%);
}

.af {
  position: absolute;
  left: 0;
  top: 0;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  color: var(--signal);
  pointer-events: none;
  will-change: transform;
  transition: color 160ms ease;
}
.af { opacity: 0; }
.af.hunting, .af.ready { opacity: 1; }
.af svg { display: block; overflow: visible; }
.af.locked { color: var(--ink); mix-blend-mode: difference; }
.af.hunting svg { animation: blink 260ms steps(1, end) infinite; }

.af-label {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 200ms ease;
}
.af.ready .af-label { opacity: 1; }
.af.flip .af-label { left: auto; right: 0; text-align: right; }

@keyframes blink { 50% { opacity: 0.15; } }

/* ---------- copy ---------- */

.copy {
  position: relative;
  z-index: 2;
  max-width: 34rem;
}

h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2.25rem, 1.4rem + 3.2vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-weight: 500;
  text-wrap: balance;
}

.copy p {
  margin: 0 0 1.6rem;
  max-width: 44ch;
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.5;
  letter-spacing: 0.005em;
  color: var(--ink-2);
  text-wrap: pretty;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  font-size: 1rem;
}
.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.35rem 0;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  transition: text-decoration-color 150ms ease, color 150ms ease;
}
.links svg {
  width: 0.9em;
  height: 0.9em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 200ms var(--ease-out);
}

@media (hover: hover) {
  .wordmark:hover { color: var(--ink-2); }
  .lang button:hover { color: var(--ink); }
  .links a:hover { text-decoration-color: var(--signal); }
  .links a:hover svg { transform: translateX(3px); }
}

/* ---------- shutter ---------- */

.shutter {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: oklch(0.06 0.004 60);
  opacity: 0;
  pointer-events: none;
}
.shutter.fire { animation: shutter 220ms ease-out; }
@keyframes shutter {
  0% { opacity: 0; }
  12% { opacity: 1; }
  45% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .hud-top { align-items: center; }
  .vf { padding-bottom: max(calc(var(--gutter) + 10px), env(safe-area-inset-bottom)); }
  .requested .label { display: none; }
  .requested { max-width: none; min-width: 0; flex: 0 1 auto; }
  .subject { min-height: clamp(8.5rem, 32svh, 18rem); margin: 0.5rem 0 1rem; }
  .num { font-size: clamp(6.5rem, min(44vw, 30svh), 14rem); }
  .copy p { margin-bottom: 1.25rem; }
  .links { gap: 0.25rem 1.5rem; }
  .hud-bottom {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 1rem;
  }
  .readout { gap: 0.35rem 1rem; }
  .readout .file { flex-basis: 100%; }
  .hint { display: none; }
  .lang { margin-right: -0.4rem; }
}

@media (max-height: 640px) and (min-width: 641px) {
  .num { font-size: clamp(7rem, 38dvh, 20rem); }
  h1 { font-size: clamp(2rem, 6dvh, 3rem); }
}

@media (prefers-reduced-motion: reduce) {
  .af.hunting svg { animation: none; }
  .shutter.fire { animation-duration: 120ms; }
  .links svg, .links a:hover svg { transition: none; transform: none; }
}
