/* ============================================================
   ACCULEAD REDESIGN — shared tokens + components
   ============================================================ */

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

:root {
  /* Palette — editorial default */
  --ink:       #0E1A30;      /* deeper, richer navy */
  --ink-soft:  #1B2A4A;
  --ink-2:     #2A3A5C;
  --paper:     #F5EFE6;      /* warm cream */
  --paper-2:   #EDE6D8;
  --white:     #FFFFFF;
  --accent:    #E8863A;      /* brand orange */
  --accent-2:  #A8541A;      /* deeper orange for text on light (WCAG AA) */
  --rule:      #D9CDB6;      /* rule/divider on cream */
  --rule-ink:  rgba(255,255,255,0.12);
  --muted:     #5A6478;
  --muted-2:   #8A94A8;

  /* Type */
  --f-display: 'DM Serif Display', 'Instrument Serif', Georgia, serif;
  --f-editor:  'Instrument Serif', Georgia, serif;
  --f-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing scale (8px base) */
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px;
  --s6: 64px; --s7: 96px; --s8: 128px;

  --maxw: 1240px;
  --maxw-narrow: 960px;
}

/* Tweaks — Operator */
body[data-theme="operator"] {
  --paper:     #F2F1EC;
  --paper-2:   #E9E7DE;
  --rule:      #D6D4CB;
  --accent:    #E8863A;
  --accent-2:  #B35F1A;
  --ink:       #0B1426;
}

/* Tweaks — Warm */
body[data-theme="warm"] {
  --ink:       #2B1810;
  --ink-soft:  #3D2517;
  --paper:     #F8F0E3;
  --paper-2:   #F0E4CF;
  --accent:    #C9532A;
  --accent-2:  #9E3B18;
  --rule:      #D8C2A0;
  --muted:     #6B5A47;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--f-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}

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

/* Keyboard focus: visible ring for keyboard users, hidden on click. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in oklab, var(--paper) 85%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-display);
  font-size: 1.55rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand img { height: 32px; width: auto; }
.brand .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 2px; transform: translateY(-6px); }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 10px 14px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0;
  position: relative;
  transition: color .15s;
}
.nav-links a:hover { color: var(--accent-2); }
.nav-links a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 4px;
  height: 2px; background: var(--accent);
}
.nav-cta {
  margin-left: 8px;
}

/* ---------- Mono label ---------- */
.eyebrow {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 24px; height: 1px; background: var(--accent);
}
.eyebrow.on-ink { color: var(--accent); }
.eyebrow.on-ink::before { background: var(--accent); }

/* Mono metadata — no leading rule */
.meta {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta-num {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--accent-2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  font-family: var(--f-body);
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: transform .15s ease, background .15s, color .15s, border-color .15s;
}
.btn-primary {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-accent { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-2); color: var(--paper); border-color: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-ghost-light { background: transparent; color: var(--paper); border-color: rgba(255,255,255,0.4); }
.btn-ghost-light:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 0.92rem;
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
  transition: color .15s, border-color .15s;
}
.btn-link:hover { color: var(--accent-2); border-color: var(--accent-2); }
.btn-arrow { font-family: var(--f-mono); font-weight: 500; }

/* ---------- Sections ---------- */
section { padding: 96px 0; }
section.tight { padding: 64px 0; }
section.loose { padding: 128px 0; }

.section-head {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 48px;
  align-items: end;
  margin-bottom: 56px;
}
.section-head h2 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.section-head p {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 44ch;
  line-height: 1.6;
}

/* ---------- Rules ---------- */
.rule {
  height: 1px; background: var(--rule); width: 100%;
}
.rule-thick { height: 3px; background: var(--ink); width: 64px; }
.rule-accent { height: 3px; background: var(--accent); width: 64px; }

/* ---------- Ink section ---------- */
.ink-section {
  background: var(--ink);
  color: var(--paper);
}
.ink-section h2, .ink-section h3 { color: var(--paper); }
.ink-section .meta { color: var(--muted-2); }
.ink-section .rule { background: var(--rule-ink); }

/* ---------- Footer ---------- */
.footer {
  background: var(--ink);
  color: var(--paper);
  padding: 80px 0 40px;
}
.footer .wrap { display: grid; gap: 64px; }
.footer-top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  align-items: start;
}
.footer-brand {
  font-family: var(--f-display);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--paper);
  letter-spacing: -0.02em;
}
.footer-tag {
  font-size: 0.92rem;
  color: rgba(245,239,230,0.65);
  margin-top: 16px;
  max-width: 36ch;
  line-height: 1.6;
}
.footer-col h3 {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}
.footer-col a {
  display: block;
  padding: 6px 0;
  font-size: 0.92rem;
  color: rgba(245,239,230,0.72);
  transition: color .15s;
}
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  padding-top: 32px;
  border-top: 1px solid var(--rule-ink);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  color: rgba(245,239,230,0.45);
  letter-spacing: 0.04em;
}
.footer-social {
  display: inline-flex; gap: 16px;
}
.footer-social a {
  width: 44px; height: 44px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(245,239,230,0.7);
  transition: all .15s;
}
.footer-social a:hover { border-color: var(--accent); color: var(--accent); }
.footer-social svg { width: 16px; height: 16px; }

/* ---------- Tweaks panel ---------- */
.tweaks-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  background: var(--ink); color: var(--paper);
  padding: 20px; border-radius: 4px;
  font-family: var(--f-mono);
  font-size: 0.75rem;
  min-width: 260px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.18);
  display: none;
}
body.tweaks-on .tweaks-panel { display: block; }
.tweaks-panel h5 {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
  font-weight: 500;
}
.tweaks-row {
  display: flex; gap: 8px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.tweaks-row:last-child { margin-bottom: 0; }
.tweaks-row label {
  display: block;
  font-size: 0.66rem;
  color: rgba(245,239,230,0.55);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: 100%;
  margin-bottom: 6px;
}
.tweaks-row button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--paper);
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  border-radius: 2px;
  transition: all .12s;
}
.tweaks-row button:hover { border-color: var(--accent); color: var(--accent); }
.tweaks-row button.active { background: var(--accent); color: var(--ink); border-color: var(--accent); }

/* ---------- Utility ---------- */
.serif { font-family: var(--f-display); font-weight: 400; letter-spacing: -0.01em; }
.editor { font-family: var(--f-editor); font-weight: 400; }
.mono   { font-family: var(--f-mono); }
.muted  { color: var(--muted); }
.accent { color: var(--accent-2); }

/* Grain overlay */
.grain::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.06 0 0 0 0 0.1 0 0 0 0 0.19 0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.09;
  mix-blend-mode: multiply;
  z-index: 1;
}

/* ---------- Mobile nav toggle ---------- */
body.nav-open {
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  width: 44px;
  height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 10px;
  cursor: pointer;
  color: inherit;
  z-index: 60;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  section { padding: 64px 0; }
  .section-head { grid-template-columns: 1fr; gap: 24px; align-items: start; }
  .footer-top { grid-template-columns: 1fr 1fr; gap: 32px; }

  .nav-toggle { display: flex; }

  /* backdrop-filter creates a containing block that traps position:fixed
     descendants. Disable it on mobile so .nav-links can position against
     the viewport. */
  .topbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--paper);
  }

  .nav-links {
    position: fixed;
    top: 72px;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--ink, #0b0b0c);
    color: #faf6ed;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 24px 24px 40px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 50;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .nav-links.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  .nav-links a {
    display: block;
    padding: 18px 4px;
    font-size: 1.25rem;
    color: #faf6ed;
    border-bottom: 1px solid rgba(250, 246, 237, .1);
  }
  .nav-links a.nav-cta {
    margin-top: 24px;
    text-align: center;
    border-bottom: 0;
    padding: 14px 18px !important;
  }
}

@media (max-width: 640px) {
  .footer-top { grid-template-columns: 1fr; gap: 32px; }
  .footer-tag { max-width: 100%; }
  .footer-bottom { flex-direction: column; gap: 12px; align-items: flex-start; text-align: left; }
  .footer-social { order: 3; }
}
