/* ==========================================================================
   TrailInk — trailink-app.com
   E-ink aesthetic: paper, ink, dither. Two themes, no external assets.
   ========================================================================== */

/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  --paper:      #f4f2ec;
  --paper-2:    #eae7de;
  --paper-3:    #e0dcd1;
  --ink:        #14130f;
  --ink-2:      #3d3a33;
  --ink-3:      #6e6a5f;
  --line:       #cfcabb;
  --line-2:     #b8b2a1;
  --accent:     #b4501c;
  --accent-ink: #fff8f2;
  --shadow:     0 1px 0 rgba(20,19,15,.06), 0 12px 32px -18px rgba(20,19,15,.35);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  --wrap: 1140px;
  --r: 4px;

  color-scheme: light;
}

[data-theme="dark"] {
  --paper:      #14130f;
  --paper-2:    #1c1a16;
  --paper-3:    #23211c;
  --ink:        #eee9dd;
  --ink-2:      #c3bcac;
  --ink-3:      #8d8677;
  --line:       #302d26;
  --line-2:     #433f36;
  --accent:     #e08a52;
  --accent-ink: #16130f;
  --shadow:     0 1px 0 rgba(0,0,0,.4), 0 18px 40px -20px rgba(0,0,0,.8);
  color-scheme: dark;
}

/* ── reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.08; letter-spacing: -.02em; font-weight: 750; }
p { margin: 0; }
code {
  font-family: var(--mono); font-size: .88em;
  background: var(--paper-3); border: 1px solid var(--line);
  padding: .08em .34em; border-radius: 3px;
}

::selection { background: var(--ink); color: var(--paper); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--ink); color: var(--paper); padding: .7rem 1rem;
}
.skip:focus { left: .5rem; top: .5rem; }

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

/* paper grain — dither-ish, very subtle */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(20,19,15,.10) .5px, transparent .6px),
    radial-gradient(circle at 3px 4px, rgba(20,19,15,.06) .5px, transparent .6px);
  background-size: 3px 3px, 7px 7px;
}
[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .35; }

/* ── layout helpers ─────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: clamp(1.15rem, 4vw, 2.5rem); }
.wrap--narrow { max-width: 760px; }
.wrap--split { display: grid; gap: clamp(2rem, 5vw, 4rem); grid-template-columns: 1.35fr .65fr; align-items: start; }
@media (max-width: 820px) { .wrap--split { grid-template-columns: 1fr; } }

.band { position: relative; z-index: 2; padding: clamp(4rem, 9vw, 7.5rem) 0; }
.band--alt { background: var(--paper-2); border-block: 1px solid var(--line); }
.band--dark { background: var(--ink); color: var(--paper); border-block: 1px solid var(--ink); }
/* the inverted band flips with the theme, so its inner tones ride currentColor */
.band--dark .kicker { color: color-mix(in srgb, currentColor 55%, transparent); }
.band--dark .prose { color: color-mix(in srgb, currentColor 78%, transparent); }

.kicker {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 1.1rem;
}
.h2 { font-size: clamp(1.85rem, 4.4vw, 3rem); max-width: 22ch; }
.prose { margin-top: 1.15rem; max-width: 62ch; color: var(--ink-2); font-size: 1.06rem; }
.prose--center { margin-top: 3rem; }
.prose a, .fineprint a, .footer a, .hero__note a, .contact__value a {
  color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em;
}
.prose a:hover { text-decoration-thickness: 2px; }
.fineprint {
  margin-top: 2.25rem; font-size: .92rem; color: var(--ink-3);
  border-left: 3px solid var(--line-2); padding-left: 1rem; max-width: 62ch;
}
.mono { font-family: var(--mono); }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  --bh: 2.85rem;
  display: inline-flex; align-items: center; gap: .5rem; justify-content: center;
  height: var(--bh); padding: 0 1.1rem;
  font: inherit; font-size: .93rem; font-weight: 600; letter-spacing: -.01em;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: transparent; color: inherit; cursor: pointer;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, color .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--sm { --bh: 2.3rem; padding: 0 .8rem; font-size: .85rem; }
.btn--solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--ghost:hover { background: var(--paper-3); border-color: var(--ink-3); }
.btn--icon { width: var(--bh); padding: 0; --bh: 2.3rem; }
.ico { width: 1.05em; height: 1.05em; fill: currentColor; flex: none; }

.theme-toggle__dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
}

/* ── topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: clamp(.75rem, 3vw, 2rem);
  padding: .7rem clamp(1.15rem, 4vw, 2.5rem);
  background: var(--paper); /* fallback where color-mix is missing */
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px) saturate(120%);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.topbar.is-stuck { border-bottom-color: var(--line); box-shadow: 0 8px 24px -22px rgba(0,0,0,.9); }
.topbar__brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: -.03em; }
.mark { width: 22px; height: 26px; fill: currentColor; }
.topbar__name { font-size: 1.06rem; }
.topbar__nav { display: flex; gap: .25rem; margin-left: auto; }
.topbar__nav a {
  font-size: .88rem; font-weight: 550; color: var(--ink-2);
  padding: .45rem .6rem; border-radius: var(--r); position: relative;
}
.topbar__nav a:hover { color: var(--ink); background: var(--paper-3); }
.topbar__nav a.is-active { color: var(--ink); }
.topbar__nav a.is-active::after {
  content: ""; position: absolute; left: .6rem; right: .6rem; bottom: .18rem;
  height: 2px; background: var(--accent);
}
.topbar__actions { display: flex; align-items: center; gap: .5rem; }
@media (max-width: 900px) { .topbar__nav { display: none; } .topbar__actions { margin-left: auto; } }

/* ── hero ───────────────────────────────────────────────────────────────── */
.hero {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1.1fr .9fr;
  gap: clamp(2rem, 5vw, 4.5rem); align-items: center;
  width: 100%; max-width: var(--wrap); margin-inline: auto;
  padding: clamp(2.5rem, 7vw, 5.5rem) clamp(1.15rem, 4vw, 2.5rem) clamp(3.5rem, 8vw, 6rem);
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }

.eyebrow {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--mono); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2); background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 999px; padding: .38rem .8rem;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

.hero__title {
  margin-top: 1.4rem;
  font-size: clamp(2.6rem, 7.2vw, 4.7rem);
  letter-spacing: -.045em; font-weight: 800;
}
.lede { margin-top: 1.4rem; font-size: clamp(1.05rem, 1.5vw, 1.18rem); color: var(--ink-2); max-width: 52ch; }
.lede strong { color: var(--ink); font-weight: 650; }

.hero__facts {
  display: flex; flex-wrap: wrap; gap: 0; margin: 2.2rem 0 0; padding: 0; list-style: none;
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--paper-2);
}
.hero__facts li { flex: 1 1 120px; padding: .9rem 1rem; border-right: 1px solid var(--line); }
.hero__facts li:last-child { border-right: 0; }
.hero__facts b { display: block; font-size: 1.5rem; letter-spacing: -.03em; }
.hero__facts span { font-size: .78rem; color: var(--ink-3); line-height: 1.35; display: block; margin-top: .1rem; }

.hero__cta { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 2rem; }
.hero__note { margin-top: 1.6rem; font-size: .84rem; color: var(--ink-3); }

/* device frame */
.hero__device { display: grid; place-items: center; }
.device { margin: 0; width: min(340px, 82vw); }
.device__body {
  position: relative; padding: 16px 14px 22px;
  background: linear-gradient(160deg, #2b2a27, #171614 55%, #232220);
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.14),
    inset 0 -2px 6px rgba(0,0,0,.6),
    0 30px 60px -28px rgba(0,0,0,.75);
}
.device__btns { position: absolute; left: -4px; top: 28%; display: grid; gap: 12px; }
.device__btns i { display: block; width: 5px; height: 34px; border-radius: 3px; background: #3a3835; }
.device__screen {
  position: relative; overflow: hidden; border-radius: 3px;
  aspect-ratio: 480 / 800; background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.5);
}
.device__screen img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.device__flash { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.device__screen.is-refreshing .device__flash { animation: eink 460ms steps(1, end); }
@keyframes eink {
  0%, 34% { opacity: .92; }
  35%, 62% { opacity: 0; }
  63%, 78% { opacity: .55; }
  79%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .device__screen.is-refreshing .device__flash { animation: none; } }

.device__cap {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  margin-top: .9rem; font-family: var(--mono); font-size: .76rem; color: var(--ink-3);
}
.tag {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  background: var(--ink); color: var(--paper); padding: .18rem .42rem; border-radius: 2px; flex: none;
}

/* ── cards ──────────────────────────────────────────────────────────────── */
.cards {
  display: grid; gap: 1rem; margin-top: 2.8rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.card {
  padding: 1.4rem 1.35rem; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--r);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.card h3 { font-size: 1.06rem; }
.card p { margin-top: .55rem; font-size: .94rem; color: var(--ink-2); }
.card--accent { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.card--accent p { color: color-mix(in srgb, currentColor 80%, transparent); }
.band--alt .card { background: var(--paper); }

/* ── gallery ────────────────────────────────────────────────────────────── */
.gallery {
  display: grid; gap: clamp(.9rem, 2vw, 1.4rem); margin-top: 2.8rem;
  grid-template-columns: repeat(3, 1fr); /* device row, then preview row */
}
@media (max-width: 760px) { .gallery { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .gallery { grid-template-columns: 1fr; } }
.shot { margin: 0; cursor: zoom-in; }
.shot img {
  width: 100%; aspect-ratio: 480 / 800; object-fit: cover;
  background: #fff; border: 1px solid var(--line-2); border-radius: 3px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.shot:hover img { transform: translateY(-3px) scale(1.006); box-shadow: var(--shadow); }
.shot figcaption {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  margin-top: .6rem; font-family: var(--mono); font-size: .73rem; color: var(--ink-3);
}
.shot .tag { background: var(--ink-3); }
.shot:nth-child(-n+3) .tag { background: var(--accent); color: var(--accent-ink); }

/* ── parts ──────────────────────────────────────────────────────────────── */
.parts { margin: 2.8rem 0 0; padding: 0; list-style: none; display: grid; gap: 0; }
.part {
  display: grid; grid-template-columns: 4rem 1fr; gap: clamp(1rem, 3vw, 2.2rem);
  padding: 1.9rem 0; border-top: 1px solid var(--line);
}
.part:last-child { border-bottom: 1px solid var(--line); }
.part__num { font-family: var(--mono); font-size: .82rem; color: var(--ink-3); padding-top: .35rem; }
.part h3 { font-size: 1.28rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.part h3 .mono {
  font-size: .68rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 999px; padding: .15rem .55rem;
}
.part p { margin-top: .65rem; color: var(--ink-2); font-size: .99rem; max-width: 64ch; }
@media (max-width: 560px) { .part { grid-template-columns: 1fr; gap: .4rem; } }

/* flow */
.flow {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem;
  margin-top: 2.6rem; padding: 1.2rem; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--r);
}
.flow__node {
  font-family: var(--mono); font-size: .78rem; color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 3px; padding: .4rem .6rem;
}
.flow__node em { color: var(--ink-3); font-style: normal; }
.flow__node--strong { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.flow__arrow { width: 22px; height: 1px; background: var(--line-2); position: relative; flex: none; }
.flow__arrow::after {
  content: ""; position: absolute; right: 0; top: -3px;
  border: 3.5px solid transparent; border-left-color: var(--line-2);
}
.flow__arrow--up { transform: rotate(180deg); }

/* ── status list ────────────────────────────────────────────────────────── */
.status { margin: 2.6rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.status li {
  display: flex; align-items: baseline; gap: 1rem; justify-content: space-between;
  padding: .78rem .2rem; border-bottom: 1px solid var(--line); font-size: .97rem;
}
.status li span { color: var(--ink-2); }
.status li b {
  flex: none; font-family: var(--mono); font-size: .7rem; letter-spacing: .09em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 2px; border: 1px solid var(--line-2); color: var(--ink-3);
}
.status .ok b { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.status .wip b { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.status li::before {
  content: ""; width: 6px; height: 6px; flex: none; margin-top: .48rem; border-radius: 50%;
  background: var(--line-2);
}
.status .ok::before { background: var(--ink); }
.status .wip::before { background: var(--accent); }

/* ── log ────────────────────────────────────────────────────────────────── */
.log {
  margin: 2.8rem 0 0; padding: 0 0 0 clamp(1.1rem, 3vw, 1.8rem); list-style: none;
  border-left: 1px solid var(--line);
}
.log li { position: relative; padding: 0 0 2.1rem; }
.log li::before {
  content: ""; position: absolute; left: calc(-1 * clamp(1.1rem, 3vw, 1.8rem) - 4.5px);
  top: .55rem; width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--line-2);
}
.log li:first-child::before { background: var(--accent); border-color: var(--accent); }
.log time { font-family: var(--mono); font-size: .74rem; letter-spacing: .06em; color: var(--ink-3); }
.log h3 { margin-top: .3rem; font-size: 1.14rem; }
.log p { margin-top: .5rem; color: var(--ink-2); font-size: .96rem; max-width: 66ch; }
.log em { font-style: italic; }

/* ── specs ──────────────────────────────────────────────────────────────── */
.specs { margin: 2.4rem 0 0; display: grid; gap: 0; }
.specs > div {
  display: grid; grid-template-columns: 8rem 1fr; gap: 1rem;
  padding: .72rem 0; border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent);
}
.specs > div:last-child { border-bottom: 1px solid color-mix(in srgb, currentColor 16%, transparent); }
.specs dt { font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: color-mix(in srgb, currentColor 55%, transparent); padding-top: .18rem; }
.specs dd { margin: 0; font-size: .98rem; }
@media (max-width: 560px) { .specs > div { grid-template-columns: 1fr; gap: .15rem; } }

.boot { margin: 0; }
.boot img {
  width: 100%; max-width: 260px; background: #fff; border-radius: 3px;
  box-shadow: 0 24px 50px -26px rgba(0,0,0,.8);
}
.boot figcaption {
  margin-top: .8rem; font-family: var(--mono); font-size: .74rem;
  color: color-mix(in srgb, currentColor 55%, transparent);
}

/* ── contact ────────────────────────────────────────────────────────────── */
.contact { display: grid; gap: 1rem; margin-top: 2.4rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.contact__card { padding: 1.5rem 1.4rem; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); }
.contact__label { font-family: var(--mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.contact__value { margin-top: .5rem; font-size: 1.04rem; font-weight: 600; word-break: break-word; }
.contact__sub { margin-top: .5rem; font-size: .88rem; color: var(--ink-3); }
.contact__card .btn { margin-top: 1rem; }

/* ── footer ─────────────────────────────────────────────────────────────── */
.footer { position: relative; z-index: 2; padding: clamp(2.5rem, 6vw, 4rem) 0 3rem; border-top: 1px solid var(--line); background: var(--paper-2); }
.footer__inner { grid-template-columns: 1fr 1.15fr; align-items: end; }
.footer__lockup { width: 280px; opacity: .9; }
.lockup-dark { display: none; }
[data-theme="dark"] .lockup-light { display: none; }
[data-theme="dark"] .lockup-dark { display: block; }
.footer__note { margin-top: 1rem; font-family: var(--mono); font-size: .76rem; color: var(--ink-3); }
.footer__credits p { font-size: .84rem; color: var(--ink-3); }
.footer__credits p + p { margin-top: .7rem; }

/* ── lightbox ───────────────────────────────────────────────────────────── */
.lb {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: rgba(10,10,8,.9); backdrop-filter: blur(6px); padding: 3.5rem 1rem;
}
.lb[hidden] { display: none; }
.lb__fig { margin: 0; display: grid; place-items: center; gap: .9rem; max-height: 100%; }
.lb__fig img {
  max-height: 76vh; width: auto; background: #fff; border-radius: 3px;
  box-shadow: 0 30px 70px -30px #000;
}
.lb__fig figcaption {
  max-width: 62ch; text-align: center; color: #d8d3c7;
  font-family: var(--mono); font-size: .8rem; line-height: 1.55;
}
.lb__close, .lb__nav {
  position: absolute; background: rgba(255,255,255,.08); color: #fff; cursor: pointer;
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--r);
  width: 2.6rem; height: 2.6rem; font-size: 1.4rem; line-height: 1;
  display: grid; place-items: center;
}
.lb__close:hover, .lb__nav:hover { background: rgba(255,255,255,.18); }
.lb__close { top: 1rem; right: 1rem; }
.lb__nav--prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb__nav--next { right: 1rem; top: 50%; transform: translateY(-50%); }

/* ── scroll reveal ──────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s ease, transform .55s ease; }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ── print ──────────────────────────────────────────────────────────────── */
@media print {
  .topbar, .grain, .lb, .hero__cta, .theme-toggle__dot { display: none !important; }
  body { background: #fff; color: #000; }
}
