/* ------------------------------------------------------------------
   Advanced Metal Research on GitHub. Tokens and components from the AMR
   website stylesheet (via the lab-notes port): ice-blue ground, ink rules,
   ticket micro-labels, dotted grids, brand red as the single accent, navy band.
   ------------------------------------------------------------------ */

:root {
  color-scheme: light;
  --ice: #d9e7eb;
  --ice-2: #c9dbe0;
  --paper: #eaf2f4;
  --ink: #1b2a30;
  --ink-2: #4e6068;
  --line: #9db3ba;
  --line-2: #b9cbd0;
  --red: #b8020d;
  --blue: #13294b;
  --blue-ink: #13294b;
  --on-blue: #eaf2f4;
  --btn-arrow: var(--red);
  --fig-bg: #fff;
  --tt-moon: block;
  --tt-sun: none;
  --sans: "Saira", "Titillium Web", "Segoe UI", Arial, sans-serif;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --measure: 38rem;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ice: #0f1c22; --ice-2: #15252c; --paper: #16262d;
  --ink: #e2edf0; --ink-2: #9bb0b7;
  --line: #3d565e; --line-2: #2b424a;
  --red: #e0343c;
  --blue: #1a355f; --blue-ink: #8fb0d9;
  --btn-arrow: #e0343c; --on-blue: #fff;
  --fig-bg: #eaf2f4;
  --tt-moon: none; --tt-sun: block;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ice: #0f1c22; --ice-2: #15252c; --paper: #16262d;
    --ink: #e2edf0; --ink-2: #9bb0b7;
    --line: #3d565e; --line-2: #2b424a;
    --red: #e0343c;
    --blue: #1a355f; --blue-ink: #8fb0d9;
    --btn-arrow: #e0343c; --on-blue: #fff;
    --fig-bg: #eaf2f4;
    --tt-moon: none; --tt-sun: block;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--ice); color: var(--ink);
  font-family: var(--sans); font-size: 1.0625rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, dl, ul, ol, figure { margin: 0; }
:focus-visible { outline: 3px solid var(--blue-ink); outline-offset: 2px; }
::selection { background: var(--red); color: #fff; }
.skip { position: absolute; left: var(--gutter); top: -3rem; background: #1b2a30; color: #eaf2f4; padding: .5rem .75rem; z-index: 100; }
.skip:focus { top: .5rem; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-2); font-style: italic; }

/* the ticket's micro-labels */
.lbl {
  font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600;
  color: var(--ink-2); white-space: nowrap;
}
.lbl b { color: var(--ink); }
.num { font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

h1 { font-size: clamp(2.8rem, 6.4vw, 6rem); line-height: .92; font-weight: 600; letter-spacing: -.035em; text-wrap: balance; }
h2 { font-size: clamp(2rem, 4.2vw, 3.6rem); line-height: 1.04; font-weight: 600; letter-spacing: -.03em; text-wrap: balance; }
h3 { font-size: 1.15rem; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
p { max-width: var(--measure); }
strong, b { font-weight: 600; }

/* buttons and links */
.btn {
  display: inline-flex; align-items: center; gap: .7rem;
  background: var(--ink); color: var(--paper); text-decoration: none;
  font-weight: 600; font-size: .95rem; padding: .85rem 1.2rem; border-radius: 3px;
}
.btn::after { content: ""; width: 8px; height: 8px; background: var(--btn-arrow); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.btn:hover { background: var(--blue); color: var(--on-blue); }
.btn-red { background: #b8020d; color: #fff; }
.btn-red::after { background: #fff; }
.btn-red:hover { background: #8e0209; color: #fff; }
.link { text-decoration: none; border-bottom: 2px solid var(--red); font-weight: 600; }
.link:hover { border-bottom-color: var(--ink); }

/* top bar as a ticket header */
.top {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2rem;
  padding: .7rem var(--gutter); background: var(--ice); border-bottom: 2px solid var(--ink);
}
.brand { display: inline-flex; align-items: center; gap: .85rem; text-decoration: none; }
.brand-mark { width: 3rem; fill: var(--red); flex: none; }
.brand-name { line-height: 1; font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand-name small { display: block; font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); margin-top: .25rem; }
.nav { display: flex; gap: 1.4rem; justify-content: center; }
.nav a { text-decoration: none; font-size: .9rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.top-end { display: flex; align-items: center; gap: .6rem; }
.theme-toggle {
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; margin: 0; padding: 0; cursor: pointer;
  background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 3px;
}
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .tt-moon { display: var(--tt-moon); }
.theme-toggle .tt-sun { display: var(--tt-sun); }
@media (max-width: 760px) {
  .top { grid-template-columns: 1fr auto; row-gap: .5rem; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; gap: 1.1rem; flex-wrap: wrap; }
  .nav a { font-size: .85rem; }
}
@media (max-width: 420px) { .brand-name small { display: none; } }

/* ticket blocks */
.ticket {
  position: relative; margin: 0 var(--gutter);
  padding: clamp(2.5rem, 5vw, 4.5rem) 0;
  border-bottom: 1px solid var(--line);
}
.ticket-head {
  display: flex; justify-content: space-between; gap: .4rem 1rem; flex-wrap: wrap;
  padding-bottom: .6rem; margin-bottom: 1.75rem; border-bottom: 1px solid var(--ink);
}
.ticket-head .lbl { white-space: normal; }
.ticket-head .dots { display: inline-flex; gap: 4px; align-items: center; }
.ticket-head .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink); display: block; }
.ticket-head .dots i:nth-child(2) { background: var(--blue-ink); }
.ticket-head .dots i:nth-child(3) { background: var(--red); width: 6px; height: 6px; }
.dotgrid { background-image: radial-gradient(var(--line-2) 1px, transparent 1.2px); background-size: 16px 16px; }

/* hero */
.hero { border-bottom: 2px solid var(--ink); }
.hero .ticket { border-bottom: 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(2rem, 4vw, 4rem); align-items: center; }
.hero-copy { display: grid; gap: 1.25rem; align-content: start; }
.seat { display: grid; gap: .2rem; }
.seat .lbl { color: var(--ink); }
.seat h1 { margin-top: .2rem; }
.hero-sub {
  width: fit-content; margin-top: 1rem; padding-top: .8rem; border-top: 2px solid var(--ink);
  font-size: clamp(1.2rem, 2vw, 1.8rem); line-height: 1.1; font-weight: 600; letter-spacing: -.02em; color: var(--ink-2);
}
.hero-lede { font-size: 1.1rem; color: var(--ink-2); max-width: 34rem; text-wrap: pretty; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center; margin-top: .5rem; }
.hero-figure { position: relative; margin: 0; }
/* hero drawing: the webp still (::before) shows without JS and under reduced motion; rosie-plot.js pen-plots the
   SVG over it, then rosie-moves.js cross-fades to the live hidden-line arm (canvas, colour from --ink) */
.hero-art { position: relative; display: block; width: 100%; aspect-ratio: 1000 / 962; }
.hero-art::before {
  content: ""; position: absolute; inset: 0;
  background: url("assets/rosie-1400-iso-ink.webp") no-repeat center / contain;
}
:root[data-theme="dark"] .hero-art::before { background-image: url("assets/rosie-1400-iso-white.webp"); opacity: .85; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-art::before { background-image: url("assets/rosie-1400-iso-white.webp"); opacity: .85; }
}
.hero-art.is-plot::before, .hero-art[data-plot="done"]::before, .hero-art.is-live::before { visibility: hidden; }
.plot-frame > .rosie-plot {
  position: absolute; inset: 0; width: 100%; height: 100%;
  overflow: visible; pointer-events: none; color: var(--ink); transition: opacity .3s linear;
}
.rosie-plot > g { stroke: currentColor; stroke-width: var(--plot-sw, 1.6); }
.rosie-plot path.fine { stroke-width: var(--plot-sw-fine, 1.1); }
.plot-frame > .rm-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  color: var(--ink); pointer-events: none; opacity: 0; transition: opacity .3s linear;
}
.plot-frame.is-live > .rm-canvas.is-cur { opacity: 1; }
.plot-frame.is-live > .rosie-plot { opacity: 0; }
.rm .rm-hud { position: absolute; right: 0; bottom: 0; pointer-events: none; opacity: 0; transition: opacity .6s ease .4s; }
.rm.is-live .rm-hud { opacity: 1; }
.hero-figure .lbl-stack { position: absolute; left: 0; bottom: 0; display: grid; gap: .3rem; background: var(--ice); padding: .5rem .65rem; border-left: 3px solid var(--red); }
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-figure { max-width: 26rem; justify-self: center; width: 100%; }
}

/* facts row */
.facts { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); border-top: 2px solid var(--ink); margin: 0; }
.facts div { padding: 1rem 1.25rem 0 0; border-right: 1px solid var(--line); display: grid; gap: .35rem; align-content: start; min-width: 0; }
.facts div + div { padding-left: 1.25rem; }
.facts div:last-child { border-right: 0; }
.facts dt { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--ink-2); }
.facts dd { margin: 0; font-size: clamp(1.8rem, 3vw, 3rem); font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.facts dd.red { color: var(--red); }
.facts p { font-size: .85rem; color: var(--ink-2); }
@media (max-width: 900px) {
  .facts { grid-template-columns: 1fr 1fr; }
  .facts div, .facts div + div { padding: .9rem 0; border-right: 0; border-bottom: 1px solid var(--line-2); }
  .facts div:nth-child(odd) { padding-right: 1rem; border-right: 1px solid var(--line-2); }
  .facts div:nth-child(even) { padding-left: 1rem; }
}

/* section intro: heading left, copy right */
.intro { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(1rem, 5vw, 5rem); align-items: start; margin-bottom: 2.25rem; }
.intro .sub { color: var(--ink-2); font-size: 1.05rem; }
@media (max-width: 900px) { .intro { grid-template-columns: 1fr; } }

/* repository cards */
.repos {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}
.repo {
  position: relative; display: flex; flex-direction: column; gap: .85rem;
  background: var(--paper); border-top: 3px solid var(--ink); border-radius: 0 0 3px 3px;
  padding: 1.1rem 1.25rem 1.35rem;
}
.repo:hover { border-top-color: var(--red); }
.repo-head { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; }
.repo-head .num { color: var(--red); }
.repo h3 { font-size: clamp(1.45rem, 2.2vw, 1.9rem); line-height: 1.05; letter-spacing: -.025em; overflow-wrap: anywhere; }
.repo h3 a { text-decoration: none; }
.repo h3 a:hover { color: var(--red); }
.repo p { color: var(--ink-2); font-size: .97rem; }
.repo .src { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--blue-ink); margin-right: .35rem; }
.topics { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  padding: .22rem .45rem; border: 1px solid var(--line); border-radius: 2px; color: var(--ink-2); white-space: nowrap;
}
.repo-stats { display: flex; gap: 1.75rem; margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--line-2); }
.repo-stats div { display: grid; gap: .1rem; }
.repo-stats dt { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--ink-2); }
.repo-stats dd { margin: 0; font-weight: 600; font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; }
.repo .btn { font-size: .88rem; padding: .65rem 1rem; }

/* archived / forks */
.archive { margin-top: 2rem; border-top: 2px solid var(--ink); }
.archive summary { cursor: pointer; padding: .9rem 0; list-style-position: inside; }
.rows { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line-2); }
.rows > li { display: grid; grid-template-columns: 14rem 7rem 1fr; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line-2); font-size: .95rem; align-items: baseline; }
.rows > li > span:last-child { color: var(--ink-2); }
@media (max-width: 760px) { .rows > li { grid-template-columns: 1fr; gap: .25rem; } }

/* write-ups */
.posts { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--ink); }
.posts > li { display: grid; grid-template-columns: 1fr; gap: clamp(1.25rem, 3vw, 2.5rem); padding: clamp(1.25rem, 2.5vw, 2rem) 0; border-bottom: 1px solid var(--line-2); align-items: start; }
.posts > li.has-thumb { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
.posts .thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 3px; border: 1px solid var(--line); background: var(--fig-bg); }
.posts .meta { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-bottom: .5rem; }
.posts .meta .lbl { white-space: normal; }
.posts h3 { font-size: clamp(1.35rem, 2.2vw, 1.9rem); line-height: 1.1; letter-spacing: -.025em; }
.posts h3 a { text-decoration: none; }
.posts h3 a:hover { color: var(--red); }
.posts p { color: var(--ink-2); margin-top: .7rem; }
@media (max-width: 760px) { .posts > li.has-thumb { grid-template-columns: 1fr; } }

/* navy band with the brand-red edge and a barcode */
.band {
  --ink: #e2edf0; --ink-2: #b4c3d6;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  background: var(--blue); color: var(--ink);
  border-top: 4px solid var(--red);
  padding: 1.25rem var(--gutter);
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 1.25rem 2rem; align-items: center;
}
.band .btn { background: var(--ink); color: #13294b; }
.band .btn:hover { background: #fff; }
:root[data-theme="dark"] .band { --ink: #1b2a30; --ink-2: #4e6068; background: #c9dbe0; }
:root[data-theme="dark"] .band .btn { color: #eaf2f4; }
:root[data-theme="dark"] .band .btn:hover { background: #13294b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .band { --ink: #1b2a30; --ink-2: #4e6068; background: #c9dbe0; }
  :root:not([data-theme="light"]) .band .btn { color: #eaf2f4; }
  :root:not([data-theme="light"]) .band .btn:hover { background: #13294b; }
}
.band .lbl-stack { display: grid; gap: .25rem; }
.barcode {
  height: 54px;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 5px, var(--ink) 5px 6px, transparent 6px 10px,
    var(--ink) 10px 13px, transparent 13px 15px, var(--ink) 15px 16px, transparent 16px 20px,
    var(--ink) 20px 22px, transparent 22px 23px, var(--ink) 23px 26px, transparent 26px 30px);
}
@media (max-width: 860px) {
  .band { grid-template-columns: 1fr 1fr; }
  .band .lbl-stack, .barcode { grid-column: 1 / -1; }
  .barcode { height: 40px; }
}
@media (max-width: 420px) { .band { grid-template-columns: 1fr; } }

/* footer */
.foot { margin: 0 var(--gutter); padding: 1.25rem 0 2.5rem; display: flex; flex-wrap: wrap; gap: .6rem 2.5rem; font-size: .8rem; color: var(--ink-2); }
.foot a { text-decoration: none; border-bottom: 1px solid var(--line); }
.foot a:hover { color: var(--ink); }

/* theme cross-fade, only when motion is welcome */
@media (prefers-reduced-motion: no-preference) {
  html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, fill .18s ease, stroke .18s ease !important;
  }
}

/* one staggered load-in for the hero and cards */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  .hero-copy > *, .hero-figure, .repo { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  .hero-copy > :nth-child(2) { animation-delay: .06s; }
  .hero-copy > :nth-child(3) { animation-delay: .12s; }
  .hero-copy > :nth-child(4) { animation-delay: .18s; }
  .hero-figure { animation-delay: .1s; }
  .repo:nth-child(2) { animation-delay: .06s; }
  .repo:nth-child(3) { animation-delay: .12s; }
  .repo:nth-child(n+4) { animation-delay: .18s; }
}
