/* ==========================================================================
   AppXLab — engineering-paper aesthetic.

   One stylesheet, no build step. The visual system is a drafting sheet:
   faint blue graph rules on warm stock, hairline registration marks,
   monospaced annotations, and a single vermilion accent used like a red
   drafting pencil — sparingly, and only where it means something.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */

:root {
  /* Warm paper stock rather than white — white reads as "unstyled". */
  --stock: #f6f4ee;
  --stock-raised: #fbfaf6;
  --ink: #16140f;
  --ink-soft: #57534a;
  --ink-faint: #8b867a;

  /* Engineering paper is ruled in faint cyan, not grey. */
  --rule: #cfd8dc;
  --rule-fine: #e2e6e4;
  --hairline: #d8d4c8;

  /* Red drafting pencil. The only saturated colour on the page. */
  --accent: #cf3a17;
  --accent-soft: rgba(207, 58, 23, 0.08);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "IBM Plex Sans", ui-sans-serif, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --grid: 34px;
  --measure: 68ch;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --stock: #100f0c;
    --stock-raised: #171612;
    --ink: #f2efe6;
    --ink-soft: #a8a294;
    --ink-faint: #6d6961;
    --rule: #24282a;
    --rule-fine: #1c1e1e;
    --hairline: #2a2721;
    --accent: #ff5c33;
    --accent-soft: rgba(255, 92, 51, 0.12);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background-color: var(--stock);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;

  /* The graph paper itself: a coarse grid over a fine one. */
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px),
    linear-gradient(var(--rule-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-fine) 1px, transparent 1px);
  background-size:
    calc(var(--grid) * 5) calc(var(--grid) * 5),
    calc(var(--grid) * 5) calc(var(--grid) * 5),
    var(--grid) var(--grid),
    var(--grid) var(--grid);
  background-position: -1px -1px;
}

/* Paper tooth. Cheap, and it stops large flat areas looking digital. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  body::after { mix-blend-mode: screen; opacity: 0.05; }
}

/* --- Structure ---------------------------------------------------------- */

.sheet {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 5vw, 4.25rem);
}

/* Registration crosshairs, as on a printed plate. Decorative only. */
.regmark {
  position: fixed;
  width: 15px;
  height: 15px;
  z-index: 3;
  pointer-events: none;
  opacity: 0.5;
}
.regmark::before,
.regmark::after {
  content: "";
  position: absolute;
  background: var(--accent);
}
.regmark::before { inset: 7px 0 auto; height: 1px; }
.regmark::after { inset: 0 auto auto 7px; width: 1px; height: 100%; }
.regmark.tl { top: 20px; left: 20px; }
.regmark.tr { top: 20px; right: 20px; }
.regmark.bl { bottom: 20px; left: 20px; }
.regmark.br { bottom: 20px; right: 20px; }

@media (max-width: 860px) {
  .regmark { display: none; }
}

/* --- Typography --------------------------------------------------------- */

.anno {
  font-family: var(--mono);
  font-size: 0.685rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
}

.anno--accent { color: var(--accent); }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.018em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.6rem, 7.5vw, 5.1rem); }
h2 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h3 { font-size: 1.32rem; line-height: 1.2; }

p { margin: 0 0 1.1em; max-width: var(--measure); }

a { color: inherit; }

.lead {
  font-size: clamp(1.05rem, 1.9vw, 1.2rem);
  color: var(--ink-soft);
  max-width: 52ch;
}

/* Hairline rule with a tick, like a dimension line. */
.rule {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 0;
  position: relative;
}
.rule::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  width: 1px;
  height: 7px;
  background: var(--accent);
}

/* --- Header ------------------------------------------------------------- */

.masthead {
  position: relative;
  z-index: 5;
  padding-block: clamp(1.5rem, 3vw, 2.4rem);
}

.masthead__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark b { color: var(--accent); font-weight: 600; }

.nav {
  display: flex;
  gap: clamp(1rem, 2.4vw, 2rem);
  font-family: var(--mono);
  font-size: 0.73rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.nav a:hover,
.nav a:focus-visible,
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

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

.hero {
  padding-block: clamp(3.5rem, 11vh, 8rem) clamp(3rem, 7vh, 5.5rem);
  position: relative;
}

.hero h1 { margin-bottom: 1.6rem; max-width: 21ch; }

/* Vermilion underline that sits under one word, drawn on load. */
.hero h1 em {
  font-style: normal;
  position: relative;
  white-space: nowrap;
}
.hero h1 em::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0.06em;
  height: 2px;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  animation: draw 0.85s 0.55s var(--ease) both;
}

@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.hero__meta {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
  margin-top: clamp(2.5rem, 6vh, 4rem);
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
}
.hero__meta div { min-width: 8rem; }
.hero__meta dd {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink);
}

/* Staggered entrance. One orchestrated load beats scattered fidgeting. */
.rise { animation: rise 0.75s var(--ease) both; }
.rise:nth-child(1) { animation-delay: 0.05s; }
.rise:nth-child(2) { animation-delay: 0.15s; }
.rise:nth-child(3) { animation-delay: 0.25s; }
.rise:nth-child(4) { animation-delay: 0.35s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* --- Sections ----------------------------------------------------------- */

.section { padding-block: clamp(3.5rem, 9vh, 6.5rem); }

.section__head {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: clamp(2rem, 4vh, 3rem);
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--hairline);
}
.section__head h2 { flex: 1; }

/* --- Spec-sheet cards --------------------------------------------------- */

.specs {
  display: grid;
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.spec {
  background: var(--stock-raised);
  padding: clamp(1.4rem, 2.6vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: relative;
  transition: background 0.25s var(--ease);
}
.spec:hover { background: var(--stock); }

/* Accent rule that draws down the left edge on hover. */
.spec::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.35s var(--ease);
}
.spec:hover::before { transform: scaleY(1); }

.spec__no {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.spec p { margin: 0; font-size: 0.95rem; color: var(--ink-soft); }

.tag {
  align-self: flex-start;
  margin-top: auto;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--hairline);
  color: var(--ink-faint);
}
.tag--live {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* --- Principles --------------------------------------------------------- */

.principles {
  display: grid;
  gap: clamp(1.75rem, 4vw, 3rem) clamp(2rem, 5vw, 4rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  counter-reset: p;
}
.principle { counter-increment: p; }
.principle h3 { margin-bottom: 0.5rem; }
.principle h3::before {
  content: counter(p, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.75rem;
}
.principle p { font-size: 0.94rem; color: var(--ink-soft); margin: 0; }

/* --- Prose (legal / support pages) -------------------------------------- */

.prose { max-width: var(--measure); padding-bottom: 2rem; }
.prose h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 2.75rem 0 0.9rem; }
.prose h3 { margin: 2rem 0 0.6rem; font-family: var(--sans); font-size: 1.02rem; font-weight: 600; letter-spacing: 0; }
.prose ul { padding-left: 1.1rem; margin: 0 0 1.1em; }
.prose li { margin-bottom: 0.45em; }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
}

.table-wrap { overflow-x: auto; margin: 1.5rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; min-width: 30rem; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border: 1px solid var(--hairline); vertical-align: top; }
th {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  background: var(--stock-raised);
}

/* A boxed aside, like a note on a drawing. */
.note {
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--accent);
  background: var(--stock-raised);
  padding: 1.1rem 1.3rem;
  margin: 1.75rem 0;
}
.note :last-child { margin-bottom: 0; }
.note p { font-size: 0.94rem; }

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

.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.8rem 1.4rem;
  border: 1px solid var(--ink);
  transition: background 0.22s var(--ease), color 0.22s var(--ease), border-color 0.22s var(--ease);
}
.btn:hover, .btn:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* --- Footer: a drawing's title block ------------------------------------ */

.titleblock {
  margin-top: clamp(3rem, 8vh, 6rem);
  border-top: 1px solid var(--ink);
}
.titleblock__grid {
  display: grid;
  gap: 1px;
  background: var(--hairline);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}
.titleblock__cell {
  background: var(--stock);
  padding: 1.1rem clamp(1rem, 2vw, 1.4rem);
}
.titleblock__cell dd {
  margin: 0.3rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.titleblock__cell a { text-decoration: none; border-bottom: 1px solid var(--hairline); }
.titleblock__cell a:hover { border-bottom-color: var(--accent); color: var(--accent); }

.colophon {
  padding-block: 1.4rem 2.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* --- Accessibility ------------------------------------------------------ */

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--stock);
  padding: 0.7rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  z-index: 10000;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
