/* Layout: a calibration worksheet - hero with a live "screen readout", then a sticky checklist rail
   beside one reading column; every test opens with the real screens it will show. */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin-var.woff2") format("woff2");
  font-weight: 400 800;
  font-stretch: 100% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Colour: matte panel greys, ink, and test-card magenta as the one accent. */
  --bg: #eff1ee;
  --surface: #fafbf9;
  --ink: #131518;
  --ink-2: #4e545a;
  --rule: #d5d8d2;
  --accent: #a8155f;
  --accent-soft: #f6e3ec;
  --ok: #146c37;
  --ok-soft: #dcefe2;
  --issue: #b53c0a;
  --issue-soft: #f8e4d9;
  --warn-bg: #fbf0cf;
  --warn-ink: #5a4200;
  /* The readout is drawn as a monitor, so it stays dark in both themes. */
  --screen: #0a0b0d;
  --screen-ink: #e8ebee;
  --screen-dim: #8c939b;
  --bezel: #23262b;
  /* Type: Archivo (expanded for display), Korean falls back per glyph to the system's Korean face. */
  --font-text: "Archivo", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  /* Hangul falls through to the Korean text face, not to a Korean monospace. */
  --font-mono: "IBM Plex Mono", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", ui-monospace, Consolas, monospace;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.7rem;
  --step-3: clamp(2.2rem, 4.6vw, 3.5rem);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --surface: #191b1e;
    --ink: #eceeea;
    --ink-2: #a7adb3;
    --rule: #2d3034;
    --accent: #ff6aae;
    --accent-soft: #3a1a2a;
    --ok: #5cd98a;
    --ok-soft: #173322;
    --issue: #ff9161;
    --issue-soft: #3b2216;
    --warn-bg: #3a3014;
    --warn-ink: #ffe08a;
    --screen: #050506;
    --bezel: #2b2f35;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111214;
  --surface: #191b1e;
  --ink: #eceeea;
  --ink-2: #a7adb3;
  --rule: #2d3034;
  --accent: #ff6aae;
  --accent-soft: #3a1a2a;
  --ok: #5cd98a;
  --ok-soft: #173322;
  --issue: #ff9161;
  --issue-soft: #3b2216;
  --warn-bg: #3a3014;
  --warn-ink: #ffe08a;
  --screen: #050506;
  --bezel: #2b2f35;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  padding-inline: clamp(16px, 4vw, 48px);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.65;
}

html:lang(ko) body { word-break: keep-all; line-height: 1.75; }

body.viewing { overflow: hidden; }

a { color: var(--accent); text-underline-offset: 0.18em; }

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

h1, h2, h3 { text-wrap: balance; font-stretch: 112%; letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); line-height: 1.2; margin: 0 0 1rem; font-weight: 700; }
h3 { font-size: var(--step-1); line-height: 1.3; margin: 0; font-weight: 700; }
p { margin: 0 0 1rem; max-width: 68ch; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05rem 0.35rem;
  background: var(--surface);
  white-space: nowrap;
}

.skip { position: absolute; left: -9999px; top: 0; padding: 0.5rem 1rem; background: var(--surface); z-index: 10; }
.skip:focus { left: 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Masthead ---- */

.masthead {
  max-width: 76rem;
  margin: 0 auto;
  padding-block: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  font-stretch: 125%;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

/* One pixel's red, green and blue subpixels: the site's mark. */
.triad { display: inline-grid; grid-template-columns: repeat(3, 5px); gap: 2px; height: 1.25rem; }
.triad i { display: block; border-radius: 1.5px; }
.triad i:nth-child(1) { background: #ff3b3b; }
.triad i:nth-child(2) { background: #2fd15a; }
.triad i:nth-child(3) { background: #3b6bff; }

.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; gap: 2px; background: var(--surface); }
.lang button {
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  padding: 0.3rem 0.85rem;
  cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---- Hero ---- */

.hero {
  max-width: 76rem;
  margin: 0 auto;
  padding-block: 2.5rem 3.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

h1 {
  font-size: var(--step-3);
  font-stretch: 122%;
  font-weight: 780;
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}
html:lang(ko) h1 { line-height: 1.25; letter-spacing: -0.03em; }
html:lang(ko) .eyebrow, html:lang(ko) .readout-title, html:lang(ko) .rail-title,
html:lang(ko) .rail-progress, html:lang(ko) .result legend { letter-spacing: 0; }

.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 36rem; }

.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-top: 1.75rem; }
.quiet { color: var(--ink); font-weight: 600; }

/* The readout: a small monitor showing what the browser detected. */
.readout { margin: 0; }
.readout-screen {
  position: relative;
  overflow: hidden;
  background: var(--screen);
  color: var(--screen-ink);
  border: 12px solid var(--bezel);
  border-bottom-width: 18px;
  border-radius: 14px;
  padding: 1.4rem 1.5rem 1.2rem;
}
.readout-screen::after {
  /* one slow scan on load, like a panel waking up */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.06) 48%, rgba(255, 255, 255, 0.12) 50%, transparent 52%);
  background-size: 100% 300%;
  background-position: 0 100%;
  animation: scan 1.8s ease-out 0.2s 1 both;
  pointer-events: none;
}
@keyframes scan { from { background-position: 0 100%; } to { background-position: 0 -100%; } }

.readout-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--screen-dim);
  margin-bottom: 0.9rem;
}
.readout-rows { margin: 0 0 1.2rem; display: grid; gap: 0.55rem; }
.readout-rows div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 1rem; border-bottom: 1px solid #1d2024; padding-bottom: 0.45rem; }
.readout-rows dt { font-size: 0.92rem; color: var(--screen-dim); }
.readout-rows dd { margin: 0; font-family: var(--font-mono); font-weight: 500; font-size: 1.35rem; font-variant-numeric: tabular-nums; text-align: right; }
.readout-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); height: 0.9rem; border-radius: 2px; overflow: hidden; }
.readout-strip .sw { width: auto; height: 100%; border: 0; border-radius: 0; aspect-ratio: auto; font-size: 0; }

.readout figcaption { padding-top: 1.1rem; }
.readout figcaption::before {
  /* the stand */
  content: "";
  display: block;
  width: 26%;
  height: 0.6rem;
  margin: -1.1rem auto 1rem;
  background: var(--bezel);
  border-radius: 0 0 6px 6px;
}
.readout .note { font-size: 0.93rem; color: var(--ink-2); }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: 0.6rem 0.9rem; font-size: 0.95rem; }

/* ---- Buttons ---- */

button { font: inherit; cursor: pointer; }
.primary, .secondary {
  font-weight: 650;
  min-height: 2.9rem;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
}
.primary { background: var(--ink); color: var(--bg); }
.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.secondary { background: transparent; color: var(--ink); }
.secondary:hover { border-color: var(--accent); color: var(--accent); }
.text-button { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 0.18em; }

/* ---- Rail and column ---- */

.layout {
  max-width: 76rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 15rem minmax(0, 46rem);
  gap: clamp(2rem, 5vw, 5rem);
  border-top: 1px solid var(--rule);
}

.rail { position: sticky; top: 1.5rem; align-self: start; padding-block: 2.5rem; }
.rail-title, .rail-progress {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.rail-title { margin-bottom: 0.6rem; }
.rail-list { list-style: none; margin: 0 0 0.9rem; padding: 0; display: grid; gap: 1px; }
.rail-list a {
  display: grid;
  grid-template-columns: 1.9rem minmax(0, 1fr) 0.7rem;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.55rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.35;
}
.rail-list a:hover { background: var(--surface); }
.rail-num { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 1.5px solid var(--ink-2); }
[data-status="ok"] .dot { background: var(--ok); border-color: var(--ok); }
[data-status="issue"] .dot { background: var(--issue); border-color: var(--issue); }
[data-status="skip"] .dot { background: var(--rule); border-color: var(--rule); }
.rail-progress { margin: 0 0 1.4rem; padding-left: 0.55rem; }
.rail-more { list-style: none; margin: 0; padding: 0.9rem 0 0 0.55rem; border-top: 1px solid var(--rule); display: grid; gap: 0.35rem; font-size: 0.93rem; }

main { min-width: 0; }

.block { padding-block: 2.75rem; border-top: 1px solid var(--rule); }
main > .block:first-child { border-top: 0; }
#tests > .block:first-of-type { border-top: 1px solid var(--rule); }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1.25rem; display: grid; gap: 0.7rem; }
.steps li { counter-increment: step; position: relative; padding-left: 2.4rem; }
.steps li::before { content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 0.2em; font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); }
.keys { color: var(--ink-2); font-size: 0.95rem; }

/* ---- A test ---- */

.test-head { display: flex; align-items: baseline; gap: 0.85rem; margin-bottom: 1.1rem; }
.num { font-family: var(--font-mono); font-weight: 500; font-size: 0.95rem; color: var(--accent); }
.test-head h3 { font-size: var(--step-2); line-height: 1.2; }

.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 0.8rem 0.8rem 0.8rem 1rem;
  margin-bottom: 1.4rem;
}
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Swatches show the real screens, so their colours are literal and the same in both themes. */
.sw {
  display: inline-grid;
  place-items: center;
  width: 3.6rem;
  aspect-ratio: 16 / 10;
  max-width: 100%;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: #000;
  font-family: var(--font-text);
  font-weight: 700;
  font-size: 0.85rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button.sw:hover { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--accent); }
.sw-white { background: #ffffff; }
.sw-black { background: #000000; }
.sw-red { background: #ff0000; }
.sw-green { background: #00ff00; }
.sw-blue { background: #0000ff; }
.sw-grey50 { background: #808080; }
.sw-grey25 { background: #404040; }
.sw-rampGrey { background: linear-gradient(90deg, #000, #fff); }
.sw-rampColour {
  background:
    linear-gradient(90deg, #000, #fff) 0 0 / 100% 25.5% no-repeat,
    linear-gradient(90deg, #000, #f00) 0 33.33% / 100% 25.5% no-repeat,
    linear-gradient(90deg, #000, #0f0) 0 66.67% / 100% 25.5% no-repeat,
    linear-gradient(90deg, #000, #00f) 0 100% / 100% 25.5% no-repeat;
}
.sw-checker { background: repeating-conic-gradient(#000 0 25%, #fff 0 50%) 0 0 / 4px 4px; }
.sw-vlines { background: repeating-linear-gradient(90deg, #fff 0 2px, #000 2px 4px); }
.sw-hlines { background: repeating-linear-gradient(0deg, #fff 0 2px, #000 2px 4px); }
.sw-text { background: #ffffff; }
.sw-motion { background: linear-gradient(#e6e6e6, #e6e6e6) 42% 50% / 24% 52% no-repeat, #141414; }

.run { white-space: nowrap; }

.looks { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 0.55rem; }
.looks li { position: relative; padding-left: 1.2rem; }
.looks li::before {
  /* a pixel-sized square bullet */
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 0.42rem;
  height: 0.42rem;
  background: var(--ink-2);
}

.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
figure { margin: 0; min-width: 0; }
figure img { display: block; width: 100%; height: auto; max-width: 100%; border-radius: 8px; }
figcaption { font-size: var(--step--1); color: var(--ink-2); margin-top: 0.45rem; line-height: 1.45; }

details { margin: 0 0 1.5rem; }
summary { cursor: pointer; font-weight: 650; }
pre {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
}

/* Result: a segmented control, coloured only once something is chosen. */
.result fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.result legend {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0;
  margin-bottom: 0.5rem;
}
.choices { display: inline-flex; flex-wrap: wrap; width: fit-content; max-width: 100%; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; gap: 3px; background: var(--surface); }
.choice { position: relative; display: inline-flex; align-items: center; min-height: 2.4rem; padding: 0.3rem 1rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.95rem; color: var(--ink-2); }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice:hover { color: var(--ink); }
.choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice-ok:has(input:checked) { background: var(--ok-soft); color: var(--ok); }
.choice-issue:has(input:checked) { background: var(--issue-soft); color: var(--issue); }
.choice-skip:has(input:checked) { background: var(--bg); color: var(--ink); }
.note-field { display: grid; gap: 0.3rem; font-size: 0.9rem; color: var(--ink-2); }

input[type="text"], textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  width: 100%;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { font-family: var(--font-mono), var(--font-text); font-size: 0.9rem; line-height: 1.6; resize: vertical; }

/* ---- Photos and results ---- */

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2rem; align-items: start; margin-bottom: 1.5rem; }
#photos h3 { margin-bottom: 0.75rem; }
.photo-list { padding-left: 1.6rem; margin: 0 0 1.5rem; columns: 2 16rem; column-gap: 2.5rem; }
.photo-list li { break-inside: avoid; margin: 0 0 0.35rem; }
.photo-list li::marker { font-family: var(--font-mono); color: var(--accent); font-size: 0.85em; }
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 0.9rem 1.1rem; max-width: none; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.9rem; }
#copy-status { color: var(--ink-2); font-size: 0.95rem; }

.footer {
  max-width: 76rem;
  margin: 0 auto;
  padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: var(--step--1);
}
.footer p { margin-bottom: 0.4rem; max-width: none; }

/* ---- Narrow screens ---- */

@media (max-width: 64rem) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rail { position: static; padding-block: 2rem 0.5rem; }
  .rail-list { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
  .rail-more { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
  main > .block:first-child { border-top: 1px solid var(--rule); }
}

@media (max-width: 52rem) {
  .hero { grid-template-columns: minmax(0, 1fr); padding-block: 1.5rem 2.5rem; }
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 30rem) {
  .strip { padding: 0.7rem; }
  .run { width: 100%; }
  .sw { width: 3.1rem; }
}

/* ---- Full-screen viewer: nothing but the test screen and a hint that fades ---- */

#viewer { position: fixed; inset: 0; z-index: 100; background: #000; cursor: default; }
#viewer[hidden] { display: none; }
#viewer.idle { cursor: none; }
#viewer canvas { display: block; position: absolute; left: 0; top: 0; }
.hint {
  position: absolute;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: rgba(20, 22, 26, 0.82);
  color: #f2f3f5;
  font-family: var(--font-text);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.hint.fade { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .hint, .sw { transition: none; }
  .readout-screen::after { animation: none; opacity: 0; }
}
