/* OPCalc site. Palette comes from the calculator itself: its slate case,
   its grey-green LCD, and the blue and green of the 2nd and ALPHA keys. */
@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "VT323";
  src: url("fonts/vt323.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --case: #232937;
  --case-2: #2f3748;
  --key: #414b60;
  --lcd: #c3cdb0;
  --lcd-ink: #1f2a1e;
  --paper: #f2f3ef;
  --rule: #d5d8cf;
  --ink: #1b2130;
  --ink-2: #4c5466;
  --second: #1f6fa8;      /* 2nd key blue, darkened for text on paper */
  --second-lit: #86c5ee;  /* the same blue on the dark case */
  --alpha: #3f7d2c;       /* ALPHA key green */
  --alpha-lit: #a3d68a;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --pixel: "VT323", "Courier New", monospace;
  --measure: 62ch;
  --gutter: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
}
img, svg { max-width: 100%; }
a { color: var(--second); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--second); outline-offset: 3px; border-radius: 2px; }
.on-case :focus-visible { outline-color: var(--second-lit); }

h1, h2, h3 { font-stretch: 78%; font-weight: 750; line-height: 1.05; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(3rem, 9vw, 6.5rem); font-stretch: 68%; font-weight: 800; }
h2 { font-size: clamp(1.9rem, 4.2vw, 3rem); }
h3 { font-size: 1.3rem; line-height: 1.2; }
p { margin: 0 0 1em; max-width: var(--measure); }

.wrap { width: min(1120px, 100% - 2 * var(--gutter)); margin-inline: auto; }

/* ---- Top bar ---- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px; }
.brand { font: 400 1.9rem/1 var(--pixel); color: inherit; text-decoration: none; }
.bar nav { display: flex; gap: clamp(14px, 3vw, 28px); font-weight: 550; }
.bar nav a { color: inherit; text-decoration: none; padding-block: 6px; border-bottom: 2px solid transparent; }
.bar nav a:hover, .bar nav a[aria-current="page"] { border-bottom-color: currentColor; }

/* ---- Dark case band ---- */
.on-case { background: var(--case); color: #eef0f4; }
.on-case a { color: var(--second-lit); }
.on-case .brand, .on-case .bar nav a { color: #eef0f4; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); gap: clamp(28px, 6vw, 80px); align-items: center; padding-block: clamp(28px, 6vw, 72px) clamp(48px, 8vw, 96px); }
.hero p.lede { font-size: clamp(1.1rem, 1.8vw, 1.3rem); line-height: 1.5; color: #cfd4de; max-width: 34ch; margin-top: 1.1em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.8em; }

.btn {
  display: inline-block; font: 650 1rem/1 var(--sans); text-decoration: none;
  padding: 15px 22px; border-radius: 9px 9px 12px 12px; /* keycap: flatter top, rounder base */
  border: 0; cursor: pointer;
}
.btn-second { background: var(--second-lit); color: #0d2233; box-shadow: 0 4px 0 #4a8fbd; }
.btn-key { background: var(--key); color: #fff; box-shadow: 0 4px 0 #1a1f2b; }
.on-case a.btn-second { color: #0d2233; }
.on-case a.btn-key { color: #fff; }
.btn:hover { transform: translateY(1px); }
.btn:active { transform: translateY(4px); box-shadow: none; }

/* ---- The LCD ---- */
.unit { background: var(--case-2); border-radius: 26px 26px 14px 14px; padding: clamp(14px, 3vw, 26px); box-shadow: inset 0 2px 0 #46506a, 0 24px 40px -18px #0b0e15; }
.unit .plate { display: flex; justify-content: space-between; font: 600 0.8rem/1 var(--sans); font-stretch: 85%; color: #aab2c3; padding: 2px 6px 12px; }
.bezel { background: #11141b; border-radius: 12px; padding: clamp(12px, 3vw, 22px); }
.lcd {
  container-type: inline-size;
  background-color: var(--lcd);
  color: var(--lcd-ink);
  border-radius: 3px;
  margin: 0;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px #9ba688, inset 0 6px 14px -8px #56603f;
}
.lcd::after { /* pixel grid: 96 columns, 8 px per text row */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(to right, rgb(195 205 176 / 0.3) 1px, transparent 1px), linear-gradient(to bottom, rgb(195 205 176 / 0.3) 1px, transparent 1px);
  background-size: calc(100% / 96) calc(100cqw / 96);
}
.lcd .row { display: grid; grid-template-columns: repeat(16, 1fr); height: calc(100cqw / 12); font: 400 calc(100cqw / 10.6) / calc(100cqw / 12) var(--pixel); }
.lcd .row span { text-align: center; white-space: pre; }
.lcd.swap .row { animation: redraw 160ms linear; }
@keyframes redraw { from { opacity: 0.2; } to { opacity: 1; } }
pre.lcd { font: 400 1.2rem/1.2 var(--pixel); padding: 8px 10px; } /* before the script lays out the grid */
pre.lcd.grid { padding: 0; }

.demo-ctl { display: flex; align-items: flex-start; gap: 12px; margin-top: 16px; }
.demo-ctl p { flex: 1; margin: 0; min-height: 4.5em; font-size: 0.98rem; line-height: 1.45; color: #d7dbe4; }
.keybtn { width: 46px; height: 40px; flex: none; border: 0; border-radius: 7px 7px 10px 10px; background: var(--key); color: #fff; font: 700 1.1rem/1 var(--sans); cursor: pointer; box-shadow: 0 3px 0 #171b25; }
.keybtn:active { transform: translateY(3px); box-shadow: none; }

/* ---- Paper sections ---- */
.section { padding-block: clamp(48px, 8vw, 104px); }
.section + .section { border-top: 1px solid var(--rule); }
.section > .wrap > h2 { margin-bottom: 0.7em; max-width: 18ch; }
.intro { font-size: 1.15rem; color: var(--ink-2); }

.menu { list-style: none; margin: 2.2em 0 0; padding: 0; border-top: 2px solid var(--ink); }
.menu li { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 8px 40px; padding-block: 22px; border-bottom: 1px solid var(--rule); align-items: baseline; }
.menu .item { font: 400 clamp(1.6rem, 2.8vw, 2.1rem)/1.1 var(--pixel); }
.menu p { margin: 0; }

.needs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 4vw, 56px); margin-top: 2em; }
.needs h3 { margin-bottom: 0.5em; }
.needs p { font-size: 1rem; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 2em 0 0; max-width: 760px; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0 18px; padding-block: 16px; }
.steps > li::before { content: counter(step); font: 400 2.4rem/0.9 var(--pixel); color: var(--second); }
.steps > li > div > :last-child { margin-bottom: 0; }

.plain { padding-left: 1.2em; max-width: var(--measure); }
.plain li { margin-bottom: 0.55em; }

kbd {
  font: 650 0.82em/1 var(--sans); font-stretch: 85%;
  display: inline-block; padding: 0.32em 0.55em 0.36em; border-radius: 5px 5px 7px 7px;
  background: var(--key); color: #fff; box-shadow: 0 2px 0 #1a1f2b; white-space: nowrap; vertical-align: 0.08em;
}
kbd.k2 { background: #5aa9db; color: #0d2233; box-shadow: 0 2px 0 #2f6f99; }
kbd.ka { background: #86c06b; color: #12280a; box-shadow: 0 2px 0 #4e8436; }
kbd.kw { background: #e9ebe6; color: var(--ink); box-shadow: 0 2px 0 #a9ad9f; }
.scr { font: 400 1.2em/1 var(--pixel); background: var(--lcd); color: var(--lcd-ink); padding: 0.15em 0.4em; border-radius: 3px; white-space: nowrap; }

.foot { padding-block: 40px 56px; font-size: 0.95rem; color: #b9c0cf; }
.foot .cols { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px 48px; }
.foot p { margin: 0 0 0.4em; max-width: 52ch; }

/* ---- Setup guide ---- */
.guide-head { padding-block: clamp(20px, 4vw, 44px) clamp(36px, 6vw, 64px); }
.guide-head h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); }
.guide-head p { color: #cfd4de; font-size: 1.15rem; margin-top: 1em; }
.guide { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(28px, 6vw, 80px); padding-block: clamp(32px, 6vw, 64px) 96px; align-items: start; }
.toc { position: sticky; top: 24px; font-size: 0.98rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule); }
.toc a { display: block; padding: 6px 0 6px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--ink); border-left-color: var(--ink); }
.chapter { padding-bottom: clamp(40px, 6vw, 64px); margin-bottom: clamp(40px, 6vw, 64px); border-bottom: 1px solid var(--rule); }
.chapter:last-child { border-bottom: 0; margin-bottom: 0; }
.chapter h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin-bottom: 0.7em; }
.chapter h3 { margin: 1.8em 0 0.6em; }
.chapter .steps { margin-top: 1em; }
.shot { width: min(300px, 100%); margin: 14px 0 6px; background: #11141b; padding: 12px; border-radius: 10px; }
.note { border-left: 4px solid var(--second); padding: 2px 0 2px 16px; margin: 1.4em 0; max-width: var(--measure); }
.note.warn { border-left-color: #b3541e; }
.note p:last-child { margin-bottom: 0; }
dl.fix { margin: 1em 0 0; max-width: 760px; }
dl.fix dt { font-weight: 700; margin-top: 1.4em; }
dl.fix dd { margin: 0.35em 0 0; }
dl.fix dd p { margin-bottom: 0.5em; }

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero p.lede { max-width: 40ch; }
  .menu li { grid-template-columns: minmax(0, 1fr); }
  .needs { grid-template-columns: minmax(0, 1fr); }
  .guide { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  .toc ol { columns: 2; column-gap: 24px; }
}
@media (max-width: 480px) {
  .steps > li { grid-template-columns: 36px minmax(0, 1fr); gap: 0 10px; }
  .toc ol { columns: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .lcd.swap .row { animation: none; }
}
