/* ==========================================================================
   Recce Co. — "The Loom" homepage comp
   Jacquard punched-card weave world. Punch-card cream / midnight-silk slate.
   ========================================================================== */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, p, figure, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
address { font-style: normal; }

/* ---- Tokens ---- */
:root {
  /* punch-card cream (light) */
  --bg: #fdfcf7;
  --surface: #e7dec7;
  --surface-2: #ded2b3;
  --ink: #211d17;
  --ink-secondary: #59503e;
  --accent: #7c5a2e;
  --accent-strong: #684a24;
  --on-accent: #f4eedb;
  --line: #c7bb98;
  --line-soft: #dbd0b3;

  --font-display: "Zilla Slab", "Iowan Old Style", Georgia, serif;
  --font-body: "Work Sans", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;

  --wrap-max: 1220px;
  --ease-loom: cubic-bezier(0.16, 1, 0.3, 1);

  --loom-sweep-duration: 24s;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1f28;
    --surface: #222834;
    --surface-2: #2a3140;
    --ink: #ece4d2;
    --ink-secondary: #a3aab8;
    --accent: #c9a468;
    --accent-strong: #d8b67d;
    --on-accent: #1a1f28;
    --line: #38414f;
    --line-soft: #2a3140;
  }
}

[data-theme="dark"] {
  --bg: #1a1f28;
  --surface: #222834;
  --surface-2: #2a3140;
  --ink: #ece4d2;
  --ink-secondary: #a3aab8;
  --accent: #c9a468;
  --accent-strong: #d8b67d;
  --on-accent: #1a1f28;
  --line: #38414f;
  --line-soft: #2a3140;
}

[data-theme="light"] {
  --bg: #fdfcf7;
  --surface: #e7dec7;
  --surface-2: #ded2b3;
  --ink: #211d17;
  --ink-secondary: #59503e;
  --accent: #7c5a2e;
  --accent-strong: #684a24;
  --on-accent: #f4eedb;
  --line: #c7bb98;
  --line-soft: #dbd0b3;
}

/* ---- Base ---- */
html {
  background: var(--bg);
  color-scheme: light dark;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s var(--ease-loom), color 0.4s var(--ease-loom);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  text-wrap: balance;
  letter-spacing: -0.02em;
}

p { color: var(--ink); }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- Selection / caret / scrollbar (browser surfaces carry the design) ---- */
::selection {
  background: var(--accent);
  color: var(--on-accent);
}

html { caret-color: var(--accent); }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--line);
  border-radius: 8px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-secondary); }

/* ---- Focus ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---- Utility ---- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  border-radius: 3px;
  z-index: 100;
  transition: top 0.2s var(--ease-loom);
  font-family: var(--font-body);
  font-weight: 600;
}
.skip-link:focus-visible {
  top: 1rem;
  outline-offset: 2px;
}

.wrap {
  max-width: var(--wrap-max);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3rem);
}

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.05rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}
.wordmark span { color: var(--accent); }

/* Header wordmark only (not the footer one): the real designed logo
   file, swapped by theme the same way the sun/moon toggle icon is —
   one asset per theme, shown/hidden via [data-theme], never redrawn
   in CSS. */
a.wordmark {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.85rem;
  transition: opacity 0.2s var(--ease-loom);
}
a.wordmark:hover { opacity: 0.75; }

.wordmark-logo {
  height: 2.1rem;
  width: auto;
}
.wordmark-logo--dark { display: none; }
[data-theme="dark"] .wordmark-logo--light { display: none; }
[data-theme="dark"] .wordmark-logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .wordmark-logo--light { display: none; }
  html:not([data-theme="light"]) .wordmark-logo--dark { display: block; }
}

.site-nav {
  display: flex;
  gap: clamp(1.1rem, 2vw, 2rem);
  flex-wrap: wrap;
}
.site-nav a {
  font-size: 0.95rem;
  color: var(--ink-secondary);
  position: relative;
  padding-bottom: 3px;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transition: right 0.25s var(--ease-loom);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { right: 0; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  transition: border-color 0.2s var(--ease-loom), color 0.2s var(--ease-loom), transform 0.2s var(--ease-loom);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 1.2rem; height: 1.2rem; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  html:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.98rem;
  padding: 0.85rem 1.4rem;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: background-color 0.2s var(--ease-loom), color 0.2s var(--ease-loom),
    border-color 0.2s var(--ease-loom), transform 0.15s var(--ease-loom);
}
.btn svg { width: 1rem; height: 1rem; flex: none; }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: var(--accent-strong); }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero-inner {
  position: relative;
  z-index: 1;
  padding-top: clamp(10rem, 22vw, 15rem);
  padding-bottom: clamp(3rem, 7vw, 5rem);
}

/* Full-bleed backdrop: the same loom artwork, unboxed, capped well under
   full strength, and faded out by the time it reaches the headline so
   type stays legible on plain background rather than fighting the grid. */
.loom-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 1.5rem clamp(1.25rem, 4vw, 3rem) 0;
  opacity: 0.75;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, black 0%, black 28%, transparent 62%);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 28%, transparent 62%);
}

.loom-svg { width: 100%; height: auto; display: block; }

.loom-svg .tick {
  font-family: var(--font-mono);
  font-size: 8.5px;
  fill: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.loom-svg .tick--row { text-anchor: end; }

.loom-svg .cell {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.loom-svg .cell--lit {
  fill: var(--accent);
  stroke: var(--accent);
  opacity: 0.88;
}

/* The 240 positions never move — the physical grid is fixed. What's
   "raised" at each position cycles right to left, script.js re-assigns
   .cell--lit on a timer by reading each fixed position's value one
   column over each tick, like a card chain feeding past a fixed reading
   head. This transition is what makes each step read as a soft light
   change rather than a hard flicker. */
@media (prefers-reduced-motion: no-preference) {
  .loom-svg .cell {
    transition: fill 0.55s var(--ease-loom), stroke 0.55s var(--ease-loom),
      opacity 0.55s var(--ease-loom);
  }
}

.loom-caption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.85rem 0.1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-secondary);
  letter-spacing: 0.03em;
  border-top: 1px solid var(--line-soft);
  margin-top: 0.6rem;
}

.hero-content {
  max-width: 46rem;
}

.hero-content h1 {
  font-size: clamp(2.5rem, 6vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.hero-role {
  margin-top: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.hero-role .sep { color: var(--line); margin-inline: 0.5em; }

.hero-lede {
  margin-top: 1.4rem;
  max-width: 42rem;
  font-size: 1.1rem;
  color: var(--ink-secondary);
}

.hero-actions {
  margin-top: 2.2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: no-preference) {
  .hero-content {
    animation: hero-rise 0.9s var(--ease-loom) both;
    animation-delay: 0.15s;
  }
  .loom-card {
    animation: loom-settle 0.9s var(--ease-loom) both;
  }
}

@keyframes hero-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loom-settle {
  from { opacity: 0; transform: translateY(-10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  padding-block: clamp(3.5rem, 8vw, 6rem);
  border-bottom: 1px solid var(--line);
}
.section:last-of-type { border-bottom: none; }

.section h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.15;
  max-width: 34ch;
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  margin-bottom: 1.25rem;
}
.section > .wrap > h2:first-child { margin-top: 0; }

.section p {
  max-width: 68ch;
  color: var(--ink-secondary);
  font-size: 1.05rem;
}

.section-lede {
  max-width: 62ch;
}

/* Method / metaphor section */
.method { background: var(--surface); }
.method .wrap > p + p { margin-top: 1.1rem; }

/* About */
.about-grid {
  display: grid;
  gap: 2rem 3rem;
  grid-template-columns: minmax(0, 1fr);
}
.about-grid h2 { margin-top: 0; }
@media (min-width: 780px) {
  .about-grid { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: start; }
}
.about-thread {
  margin-top: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-secondary);
}
.about-thread::before {
  content: "";
  width: 2.5rem;
  height: 1px;
  background: var(--accent);
}

.about-body-spaced {
  margin-top: 1.75rem;
}

/* ---- Ledger list (industries) ---- */
.ledger {
  margin-top: 2.5rem;
  border-top: 1px solid var(--line);
}
.ledger-row {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  gap: 0.4rem 1.5rem;
  padding-block: 1.6rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) {
  .ledger-row { grid-template-columns: 4.2rem minmax(0, 1fr); gap: 0.5rem 2.25rem; }
}
.ledger-ref {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  padding-top: 0.2rem;
}
.row-content > * + * { margin-top: 0.4rem; }
@media (min-width: 720px) {
  .row-content {
    display: flex;
    gap: 2.25rem;
    align-items: baseline;
  }
  .row-content > * + * { margin-top: 0; }
  .row-content h3 { flex: 0 0 15rem; }
  .row-content p { flex: 1; }
}
.ledger-row h3 {
  font-size: 1.2rem;
  font-weight: 600;
}
.ledger-row p {
  color: var(--ink-secondary);
  font-size: 0.98rem;
  max-width: 52ch;
}

/* ---- Case studies ---- */
.cases {
  margin-top: 2.5rem;
  border-top: 1px solid var(--line);
}
.case {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  padding-block: 2.1rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) {
  .case { grid-template-columns: 5.4rem minmax(0, 1fr); }
}
.case-ref {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  padding-top: 0.3rem;
  white-space: nowrap;
}
.case h3 {
  font-size: clamp(1.25rem, 2.4vw, 1.55rem);
  max-width: 34ch;
  margin-bottom: 0.6rem;
}
.case p {
  color: var(--ink-secondary);
  max-width: 62ch;
}
.case-meta {
  display: block;
  margin-top: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-secondary);
  letter-spacing: 0.02em;
}
.case-meta::before {
  content: "";
  display: inline-block;
  width: 1.4em;
  border-top: 1px solid var(--accent);
  vertical-align: middle;
  margin-right: 0.6em;
}

/* ---- Testimonials ---- */
.testimonials-list {
  margin-top: 2.5rem;
  border-top: 1px solid var(--line);
}
.testimonial {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  padding-block: 2.1rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) {
  .testimonial { grid-template-columns: 11rem minmax(0, 1fr); }
}

.testimonial-byline {
  padding-top: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}
.testimonial-name {
  color: var(--accent);
}
.testimonial-role {
  max-width: 16ch;
}

.testimonial-quote {
  margin: 0;
  grid-column: 2;
}
.quote-lede {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  max-width: 58ch;
}
.quote-rest-wrap {
  position: relative;
  display: grid;
  grid-template-rows: 6.5em;
  overflow: hidden;
  transition: grid-template-rows 0.45s var(--ease-loom);
}
.quote-rest-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.4em;
  background: linear-gradient(to bottom, transparent, var(--bg));
  transition: opacity 0.3s var(--ease-loom);
}
.quote-rest p {
  color: var(--ink-secondary);
  max-width: 58ch;
  margin-top: 0.9rem;
}
.quote-rest p + p { margin-top: 0.7rem; }

.testimonial:hover .quote-rest-wrap,
.testimonial:focus-within .quote-rest-wrap,
.testimonial.is-expanded .quote-rest-wrap {
  grid-template-rows: var(--full-h, 30rem);
}
.testimonial:hover .quote-rest-wrap::after,
.testimonial:focus-within .quote-rest-wrap::after,
.testimonial.is-expanded .quote-rest-wrap::after {
  opacity: 0;
}

.quote-toggle {
  grid-column: 2;
  justify-self: start;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 0.1rem;
  transition: color 0.2s var(--ease-loom), border-color 0.2s var(--ease-loom);
}
.testimonial:hover .quote-toggle,
.testimonial:focus-within .quote-toggle {
  color: var(--accent-strong);
  border-color: var(--accent-strong);
}
/* ---- Contact ---- */
.contact { background: var(--surface); }
.contact-inner p,
.contact-inner .contact-email {
  max-width: 44rem;
}
.contact-email {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 0.3rem;
  transition: color 0.2s var(--ease-loom), border-color 0.2s var(--ease-loom);
}
.contact-email svg { width: 1rem; height: 1rem; }
.contact-email:hover { color: var(--accent-strong); border-color: var(--accent-strong); }

.contact-detail {
  margin-top: 1.75rem;
  color: var(--ink-secondary);
  max-width: 40ch;
}

/* ---- Footer ---- */
.site-footer {
  padding-block: 2.75rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}
.footer-inner .wordmark { font-size: 1rem; }
.footer-tagline { color: var(--ink-secondary); }
.footer-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-meta a:hover { color: var(--accent); }

/* ---- Responsive tweaks ---- */
@media (max-width: 480px) {
  .loom-svg .tick { display: none; }
  .loom-card { padding-top: 0.5rem; }
}
