/* =========================================================
   LagLab — design tokens (v2)
   "Diagnostic ticket" aesthetic: printed lab report / carbon-copy
   requisition form. Sharp edges, ruled lines, ink stamps.
========================================================= */

:root{
  --paper:       #EDF1EA;
  --paper-alt:   #E3E9E0;
  --surface:     #FFFFFF;
  --line:        #C6D0C2;
  --ink:         #16180F;
  --muted:       #565A4C;
  --muted-2:     #8A8F7C;

  --stamp-red:   #B23A2E;
  --stamp-red-bg:#F5E4E1;
  --stamp-green: #2F6B45;
  --stamp-green-bg:#E4EDE2;

  --radius: 2px;
  --maxw: 1120px;

  --font-display: 'Space Mono', 'Courier New', monospace;
  --font-body: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }

body{
  margin:0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img{ max-width:100%; display:block; }
a{ color: inherit; }

h1,h2,h3,h4{
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 0.5em 0;
  letter-spacing: -0.01em;
  text-transform: none;
}
h1{ font-size: clamp(2rem, 4vw, 3.1rem); font-weight:700; }
h2{ font-size: clamp(1.3rem, 2.4vw, 1.8rem); font-weight:700; }
h3{ font-size: 1.05rem; font-weight:700; }
p{ margin: 0 0 1em 0; color: var(--ink); }
.muted{ color: var(--muted); }

.wrap{ max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Form-label style eyebrow ---------- */
.eyebrow{
  display:inline-flex; align-items:center; gap:8px;
  font-family: var(--font-mono); font-size:0.72rem; letter-spacing:0.1em;
  text-transform:uppercase; color: var(--muted);
  border:1px solid var(--ink); padding: 5px 10px; border-radius:0;
}
.eyebrow::before{ content:'§'; }

/* ---------- Nav: ruled header, not a floating pill bar ---------- */
.site-nav{
  position: sticky; top:0; z-index: 50;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}
.site-nav .wrap{
  display:flex; align-items:center; justify-content:space-between;
  height: 66px;
}
.brand{
  display:flex; align-items:center; gap:8px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.05rem; letter-spacing:0.02em;
  text-decoration:none; color: var(--ink);
  border:2px solid var(--ink); padding:6px 10px;
}
.brand .dot{
  width:8px; height:8px; background: var(--stamp-red); flex-shrink:0;
}
.nav-links{ display:flex; gap: 26px; align-items:center; list-style:none; margin:0; padding:0; }
.nav-links a{
  text-decoration:none; color: var(--ink); font-weight:500; font-size:0.88rem;
  font-family: var(--font-mono); text-transform:uppercase; letter-spacing:0.04em;
}
.nav-links a:hover{ color: var(--stamp-red); }
.nav-cta{
  background: var(--ink); color: var(--paper) !important;
  padding: 9px 16px !important;
}
.nav-cta:hover{ color: var(--paper) !important; background: var(--stamp-red); }
.nav-toggle{ display:none; }

@media (max-width: 720px){
  .nav-links{
    position:absolute; top:66px; left:0; right:0;
    background: var(--paper); border-bottom:2px solid var(--ink);
    flex-direction:column; align-items:flex-start; padding: 16px 24px; gap:16px;
    display:none;
  }
  .nav-links.open{ display:flex; }
  .nav-toggle{
    display:block; background:none; border:2px solid var(--ink);
    padding:6px 10px; font-size:1.05rem; cursor:pointer; font-family:var(--font-mono);
  }
}

/* ---------- Buttons: stamped rectangles, not pills ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding: 13px 22px;
  border-radius: var(--radius);
  font-weight: 700; font-size: 0.85rem;
  font-family: var(--font-mono); text-transform:uppercase; letter-spacing:0.04em;
  text-decoration:none; cursor:pointer;
  border: 2px solid var(--ink);
  transition: background .12s ease, color .12s ease;
}
.btn-primary{ background: var(--ink); color: var(--paper); }
.btn-primary:hover{ background: var(--stamp-red); border-color: var(--stamp-red); }
.btn-ghost{ background: transparent; color: var(--ink); }
.btn-ghost:hover{ background: var(--ink); color: var(--paper); }
.btn-block{ width:100%; }

/* ---------- Hero ---------- */
.hero{ padding: 60px 0 50px; }
.hero-grid{
  display:grid; grid-template-columns: 1.05fr 0.95fr; gap: 48px; align-items:start;
}
@media (max-width: 900px){ .hero-grid{ grid-template-columns: 1fr; } }
.hero p.lead{ font-size:1.08rem; color: var(--muted); max-width: 48ch; }
.hero-actions{ display:flex; gap:14px; margin-top: 26px; flex-wrap:wrap; }
.hero-note{ margin-top:14px; font-size:0.8rem; font-family:var(--font-mono); color: var(--muted-2); }
.hero .eyebrow{ margin-bottom:18px; }

/* Signature element: Diagnostic Ticket */
.readout{
  position:relative;
  background: var(--surface);
  border: 2px solid var(--ink);
  padding: 26px 22px 22px;
  background-image: radial-gradient(circle, var(--paper) 3px, transparent 3px);
  background-size: 16px 16px;
  background-position: -8px 0;
  background-repeat: repeat-y;
  padding-left: 34px;
}
.readout::before{
  content:'';
  position:absolute; left:16px; top:0; bottom:0;
  border-left: 2px dashed var(--line);
}
.readout-head{
  display:flex; justify-content:space-between; align-items:flex-start;
  font-family: var(--font-mono); font-size:0.72rem; color: var(--muted-2);
  text-transform:uppercase; letter-spacing:0.06em;
  margin-bottom: 18px; padding-bottom:14px; border-bottom:1px dashed var(--line);
}
.readout-head .ticket-id{ display:block; margin-top:4px; color:var(--ink); font-weight:700; }

.stamp{
  font-family: var(--font-display); font-weight:700; font-size:0.85rem;
  text-transform:uppercase; letter-spacing:0.06em;
  border: 3px solid var(--stamp-red); color: var(--stamp-red);
  padding: 6px 12px; transform: rotate(-6deg);
  display:inline-block;
}
.stamp.is-clear{ border-color: var(--stamp-green); color: var(--stamp-green); }

.readout-rows{ display:flex; flex-direction:column; gap:10px; margin-top:18px; }
.readout-row{
  display:grid; grid-template-columns: 76px 1fr auto; align-items:center; gap:14px;
  padding: 9px 0; border-bottom: 1px dotted var(--line);
  font-family: var(--font-mono);
}
.readout-row .label{ font-size:0.76rem; color:var(--muted); font-weight:700; text-transform:uppercase; letter-spacing:0.04em; }
.readout-row .bar{ height:6px; background: var(--paper-alt); overflow:hidden; }
.readout-row .bar span{ display:block; height:100%; transition: width .6s ease, background .6s ease; }
.readout-row .val{ font-weight:700; font-size:0.85rem; min-width:64px; text-align:right; }

.state-bad .bar span{ background: var(--stamp-red); }
.state-bad .val{ color: var(--stamp-red); }
.state-good .bar span{ background: var(--stamp-green); }
.state-good .val{ color: var(--stamp-green); }

.readout-toggle{ display:flex; justify-content:center; margin-top:20px; padding-top:16px; border-top:1px dashed var(--line); }
.readout-toggle button{
  font-family: var(--font-mono); font-size:0.72rem; text-transform:uppercase;
  letter-spacing:0.05em; background:none; border:2px solid var(--ink);
  padding:8px 16px; cursor:pointer; color:var(--ink);
}
.readout-toggle button:hover{ background: var(--ink); color: var(--paper); }

/* ---------- Sections ---------- */
section{ padding: 56px 0; border-bottom: 1px dashed var(--line); }
section:last-of-type{ border-bottom:none; }
.section-head{ max-width: 640px; margin-bottom: 36px; }
.section-head .eyebrow{ margin-bottom:14px; }

.grid-3{ display:grid; grid-template-columns: repeat(3,1fr); gap: 0; border-top:2px solid var(--ink); }
.grid-2{ display:grid; grid-template-columns: repeat(2,1fr); gap: 22px; }
@media (max-width: 860px){ .grid-3{ grid-template-columns:1fr; } .grid-2{ grid-template-columns:1fr; } }

.card{
  background: transparent;
  border-right: 1px dashed var(--line);
  border-bottom: 2px solid var(--ink);
  padding: 24px 22px;
}
.grid-3 .card:last-child{ border-right:none; }
.card .icon{
  font-family: var(--font-mono); font-weight:700; color: var(--ink);
  margin-bottom:14px; font-size:0.8rem;
}
.card .icon::before{ content:'#'; color: var(--stamp-red); }

.steps{ display:flex; flex-direction:column; gap:0; border-top:2px solid var(--ink); }
.step{
  display:grid; grid-template-columns: 60px 1fr; gap:20px;
  padding: 22px 0; border-bottom:1px dashed var(--line);
}
.step .num{
  font-family: var(--font-mono); font-size:1.3rem; font-weight:700; color: var(--muted-2);
}

/* ---------- Diagnostic ledger (infographic) ---------- */
.diag-chart{ display:flex; flex-direction:column; gap:0; border-top:2px solid var(--ink); }
.diag-row{
  display:grid; grid-template-columns: 170px 1fr 90px; align-items:center; gap:16px;
  padding: 14px 0; border-bottom: 1px dashed var(--line);
  font-family: var(--font-mono);
}
.diag-row .name{ font-weight:700; font-size:0.85rem; text-transform:uppercase; letter-spacing:0.03em; }
.diag-row .track{ height:8px; background: var(--paper-alt); overflow:hidden; }
.diag-row .fill{ height:100%; background: var(--ink); }
.diag-row .pct{ font-size:0.72rem; text-align:right; color:var(--muted); text-transform:uppercase; letter-spacing:0.04em; }
.diag-caption{ font-size:0.8rem; color: var(--muted-2); margin-top:14px; font-family:var(--font-mono); }

/* ---------- Tool page ---------- */
.tool-shell{
  background: var(--surface); border: 2px solid var(--ink);
  padding: 30px; max-width: 720px; margin: 0 auto;
}
.field{ margin-bottom:22px; }
.field label{ display:block; font-weight:700; font-size:0.85rem; margin-bottom:10px; font-family: var(--font-mono); text-transform:uppercase; letter-spacing:0.02em; }
.field select, .field input[type="text"]{
  width:100%; padding: 12px 14px; border-radius: var(--radius);
  border:2px solid var(--ink); background: var(--paper); font-family: var(--font-body);
  font-size:0.95rem; color: var(--ink);
}
.radio-group{ display:flex; flex-wrap:wrap; gap:10px; }
.radio-pill{
  border:2px solid var(--ink); border-radius: var(--radius); padding:9px 14px;
  font-size:0.8rem; cursor:pointer; background: var(--paper); color: var(--ink);
  font-family: var(--font-mono); text-transform:uppercase; letter-spacing:0.02em;
}
.radio-pill input{ display:none; }
.radio-pill.active{ background: var(--ink); color: var(--paper); }

.progress-bar{ height:4px; background: var(--paper-alt); margin-bottom:28px; overflow:hidden; }
.progress-bar span{ display:block; height:100%; background: var(--ink); width:0%; transition: width .4s ease; }

.result-score{
  display:flex; align-items:center; gap:20px; padding:20px; border: 2px solid var(--ink);
  margin-bottom: 26px;
}
.result-score .num{ font-family: var(--font-mono); font-size:2rem; font-weight:700; color: var(--stamp-red); }
.checklist-group{ margin-bottom: 26px; }
.checklist-group h4{ font-family: var(--font-mono); font-size:0.75rem; text-transform:uppercase; letter-spacing:0.06em; color: var(--muted-2); margin-bottom:12px; border-bottom:1px dashed var(--line); padding-bottom:8px; }
.checklist-item{
  display:flex; gap:12px; padding:14px 0; border-bottom:1px dotted var(--line);
}
.checklist-item .mark{ color: var(--stamp-green); font-weight:700; font-family:var(--font-mono); }
.aff-note{
  font-size:0.78rem; color: var(--muted-2); border-top:1px dashed var(--line); margin-top:8px; padding-top:10px; font-family:var(--font-mono);
}

/* ---------- Reviews ---------- */
.review-card{ background: var(--surface); border:2px solid var(--ink); padding: 22px; }
.review-empty{
  border:2px dashed var(--ink); padding: 32px;
  text-align:center; color: var(--muted); font-family:var(--font-mono); font-size:0.9rem;
}

/* ---------- Blog ---------- */
.post-card{
  display:block; text-decoration:none; color:inherit;
  background: transparent; border-bottom:2px solid var(--ink);
  padding: 22px 0; margin-bottom: 0;
}
.post-card .tag{
  font-family: var(--font-mono); font-size:0.7rem; text-transform:uppercase;
  color: var(--stamp-red); margin-bottom:8px; display:block; letter-spacing:0.05em;
}
.post-body{ max-width: 68ch; margin: 0 auto; }
.post-body h2{ margin-top:1.4em; }
.post-body ul, .post-body ol{ padding-left: 1.2em; }
.post-body li{ margin-bottom:0.5em; }

/* ---------- Motion & hover polish ---------- */
@media (prefers-reduced-motion: no-preference){
  .card, .step, .post-card, .review-card{
    transition: transform .18s ease, background-color .18s ease;
  }
  .card:hover{ transform: translateY(-3px); background: var(--surface); }
  .step:hover{ background: var(--surface); }
  .post-card:hover{ transform: translateX(4px); background: var(--surface); }

  .btn{ transition: background .12s ease, color .12s ease, transform .12s ease; }
  .btn:active{ transform: translateY(1px); }

  .nav-links a{ transition: color .12s ease, transform .12s ease; position:relative; }
  .nav-links a:hover{ transform: translateY(-1px); }

  .readout{ transition: transform .2s ease; }
  .readout:hover{ transform: translateY(-2px); }

  .diag-row .fill{
    width: 0 !important;
    animation: fillIn 1.1s ease forwards;
    animation-delay: calc(var(--i, 0) * 120ms);
  }
  @keyframes fillIn{ to{ width: var(--target, 85%); } }

  .reveal{ opacity:0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
  .reveal.is-visible{ opacity:1; transform: translateY(0); }

  .checklist-item{ transition: background-color .15s ease, padding-left .15s ease; }
  .checklist-item:hover{ background: var(--paper-alt); padding-left:8px; }

  .radio-pill{ transition: transform .12s ease, background .12s ease, color .12s ease; }
  .radio-pill:hover{ transform: translateY(-2px); }
}

/* ---------- Form alerts (auth errors) ---------- */
.form-alert{
  border: 2px solid var(--stamp-red); background: var(--stamp-red-bg); color: var(--stamp-red);
  padding: 12px 14px; font-family: var(--font-mono); font-size:0.82rem;
}

/* ---------- Game search (autocomplete) ---------- */
.game-search{ position:relative; }
.game-search input{
  width:100%; padding: 13px 14px; border:2px solid var(--ink); background: var(--paper);
  font-family: var(--font-body); font-size:0.95rem; color: var(--ink); border-radius: var(--radius);
}
.game-search-results{
  position:absolute; left:0; right:0; top: calc(100% + 4px); z-index: 20;
  background: var(--surface); border: 2px solid var(--ink); max-height: 260px; overflow-y:auto;
  display:none;
}
.game-search-results.open{ display:block; }
.game-search-item{
  padding: 10px 14px; cursor:pointer; font-size:0.9rem; border-bottom:1px dashed var(--line);
}
.game-search-item:last-child{ border-bottom:none; }
.game-search-item:hover{ background: var(--paper-alt); }
.game-selected{
  margin-top:10px; display:none; align-items:center; justify-content:space-between;
  border: 2px solid var(--ink); padding: 10px 14px; font-family: var(--font-mono); font-size:0.85rem;
}
.game-selected.open{ display:flex; }
.game-selected button{ background:none; border:none; color: var(--stamp-red); cursor:pointer; font-family:var(--font-mono); font-weight:700; }

/* ---------- Spec comparison ---------- */
.spec-compare{ border: 2px solid var(--ink); margin-bottom:26px; }
.spec-compare-head{ font-family: var(--font-mono); font-size:0.75rem; text-transform:uppercase; letter-spacing:0.05em; padding:12px 14px; border-bottom:2px solid var(--ink); background: var(--paper-alt); }
.spec-compare-body{ display:grid; grid-template-columns: 1fr 1fr; }
.spec-col{ padding:14px; font-size:0.82rem; font-family: var(--font-mono); white-space:pre-line; }
.spec-col:first-child{ border-right:1px dashed var(--line); }
.spec-col h5{ margin:0 0 8px; text-transform:uppercase; font-size:0.72rem; color: var(--muted-2); }
@media (max-width:640px){ .spec-compare-body{ grid-template-columns:1fr; } .spec-col:first-child{ border-right:none; border-bottom:1px dashed var(--line); } }

/* ---------- Chat widget ---------- */
#laglab-chat-toggle{
  position:fixed; bottom:22px; right:22px; z-index:80;
  width:56px; height:56px; border-radius:50%; background: var(--ink); color: var(--paper);
  border:2px solid var(--ink); font-family: var(--font-mono); font-size:1.3rem;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
  box-shadow: 0 10px 24px rgba(22,24,15,0.28);
}
#laglab-chat-toggle:hover{ background: var(--stamp-red); border-color: var(--stamp-red); }

#laglab-chat-panel{
  position:fixed; bottom:88px; right:22px; z-index:80;
  width: min(340px, calc(100vw - 44px)); height: 440px;
  background: var(--surface); border: 2px solid var(--ink);
  display:none; flex-direction:column; overflow:hidden;
  box-shadow: 0 16px 40px rgba(22,24,15,0.22);
}
#laglab-chat-panel.open{ display:flex; }
.chat-head{
  background: var(--ink); color: var(--paper); padding:12px 14px;
  font-family: var(--font-mono); font-size:0.8rem; text-transform:uppercase; letter-spacing:0.05em;
  display:flex; justify-content:space-between; align-items:center;
}
.chat-head button{ background:none; border:none; color: var(--paper); font-size:1rem; cursor:pointer; }
.chat-messages{ flex:1; overflow-y:auto; padding: 14px; display:flex; flex-direction:column; gap:10px; }
.chat-msg{ font-size:0.85rem; line-height:1.4; max-width:88%; padding:8px 10px; border:1px solid var(--line); }
.chat-msg.user{ align-self:flex-end; background: var(--paper-alt); border-color: var(--ink); }
.chat-msg.bot{ align-self:flex-start; background: var(--surface); }
.chat-msg.typing{ color: var(--muted-2); font-family: var(--font-mono); font-style: italic; }
.chat-input-row{ display:flex; border-top:2px solid var(--ink); }
.chat-input-row input{
  flex:1; border:none; padding:12px; font-family: var(--font-body); font-size:0.88rem; background: var(--paper);
}
.chat-input-row button{
  border:none; background: var(--ink); color: var(--paper); padding: 0 16px; cursor:pointer;
  font-family: var(--font-mono); font-weight:700;
}
.chat-input-row button:hover{ background: var(--stamp-red); }

footer{ border-top:2px solid var(--ink); padding: 34px 0; margin-top: 0; }
.footer-grid{ display:flex; justify-content:space-between; flex-wrap:wrap; gap:20px; align-items:center; }
.footer-links{ display:flex; gap:20px; list-style:none; margin:0; padding:0; }
.footer-links a{ text-decoration:none; color: var(--muted); font-size:0.78rem; font-family:var(--font-mono); text-transform:uppercase; letter-spacing:0.03em; }
.footer-links a:hover{ color: var(--ink); }
