/* drafts/03-publish/styles.css */

/* ==================================================================
   1. Tokens
   Swap palette, fonts, and spacing here. Contrast notes:
   - --wine is too dark for text or icons on --bg (about 1.8:1);
     use it for filled surfaces only (cream text on wine is ~10:1).
   - --wine-bright is the red for lines and icons (~3.4:1).
   - --gold is safe for small text (~8.5:1).
   ================================================================== */

:root {
  --bg: #060404;
  --bg-raised: #0c0808;
  --bg-hover: #100b0b;
  --cream: #f6f2eb;
  --taupe: #b3a89c;
  --ash: #8a8079;
  --wine: #6b1d1f;
  --wine-hover: #7d2326;
  --wine-bright: #b2393c;
  --gold: #c4a44a;
  --line: rgba(246, 242, 235, 0.12);
  --line-strong: rgba(246, 242, 235, 0.28);

  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas,
    monospace;

  --max: 1320px;
  --gutter: clamp(1rem, 5vw, 5rem);
  --section: clamp(5rem, 12vw, 10rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==================================================================
   2. Base
   ================================================================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--cream);
  font-family: var(--serif);
  font-size: clamp(1.125rem, 0.4vw + 1rem, 1.3rem);
  line-height: 1.6;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #170d0d, transparent 70%)
      fixed,
    var(--bg);
  /* Custom cursor: swap cursor.svg; "16 16" is the hotspot. */
  cursor: url("cursor.svg") 16 16, crosshair;
}

/* Grain + faint scanlines over everything. Tweak opacity to taste. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.025) 0 1px,
      transparent 1px 3px
    ),
    url("grain.svg");
  opacity: 0.06;
  pointer-events: none;
}

a,
button {
  cursor: pointer;
}

a {
  color: inherit;
}

em {
  font-style: italic;
}

:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 4px;
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: var(--gutter);
  z-index: 300;
  padding: 0.75rem 1rem;
  background: var(--cream);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.skip-link:focus {
  top: 1rem;
}

/* Small uppercase monospace label used for overlines and metadata. */
.overline {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ==================================================================
   3. Pre-loader
   Pure CSS: plays only when <html> has class="preload" (set by the
   inline script in index.html, once per session). Timing lives in
   the two animations below.
   ================================================================== */

.preloader {
  display: none;
}

.preload .preloader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.25rem;
  background: var(--bg);
  animation: preloader-out 0.5s var(--ease) 0.9s forwards;
}

.preloader-title {
  padding-left: 0.5em;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
}

.preloader-line {
  position: relative;
  width: min(240px, 60vw);
  height: 1px;
  overflow: hidden;
  background: var(--line);
}

.preloader-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--wine-bright);
  transform: scaleX(0);
  transform-origin: left;
  animation: preloader-load 0.8s var(--ease) forwards;
}

@keyframes preloader-load {
  to {
    transform: scaleX(1);
  }
}

@keyframes preloader-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* Hero reveals wait for the pre-loader to clear. */
.preload .hero {
  --base: 1s;
}

/* ==================================================================
   4. Background art
   The inline SVG in .backdrop floats behind everything. Replace the
   SVG in index.html; opacity and drift speed are set here.
   ================================================================== */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.backdrop svg {
  width: max(120vmin, 900px);
  height: auto;
  color: var(--gold);
  opacity: 0.08;
}

@media (prefers-reduced-motion: no-preference) {
  .backdrop svg {
    animation: drift 240s linear infinite;
  }
}

@keyframes drift {
  to {
    transform: rotate(360deg);
  }
}

/* ==================================================================
   5. Navigation
   ================================================================== */

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem var(--gutter);
  background: rgba(6, 4, 4, 0.55);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  text-decoration: none;
}

.logo::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--wine-bright);
}

.nav ul {
  display: flex;
  gap: clamp(1.25rem, 3vw, 3rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav ul a {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--taupe);
  transition: color 0.3s ease;
}

.nav ul a:hover {
  color: var(--cream);
}

.nav .nav-cta a {
  color: var(--gold);
}

/* Small screens keep only the CTA link. */
@media (max-width: 759px) {
  .nav li:not(.nav-cta) {
    display: none;
  }
}

/* ==================================================================
   6. Buttons
   .btn-solid = primary, .btn-outline = secondary.
   Add class="magnetic" for the cursor-follow effect (main.js).
   ================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  padding: 1.05rem 1.6rem;
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
  transition:
    transform 0.35s var(--ease),
    box-shadow 0.4s ease,
    background-color 0.4s ease,
    border-color 0.4s ease;
}

.btn-solid {
  background: var(--wine);
  border-color: var(--wine);
  color: var(--cream);
}

.btn-solid:hover {
  background: var(--wine-hover);
  box-shadow:
    0 0 0 1px rgba(178, 57, 60, 0.5),
    0 0 36px rgba(178, 57, 60, 0.35);
}

.btn-outline {
  border-color: var(--line-strong);
  color: var(--cream);
}

.btn-outline:hover {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(196, 164, 74, 0.15);
}

/* ==================================================================
   7. Layout helpers
   ================================================================== */

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--section) var(--gutter) 0;
}

.section-head {
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

h2 {
  max-width: 18ch;
  margin: 0.9rem 0 0;
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.015em;
}

h2 em {
  color: var(--taupe);
}

/* ==================================================================
   8. Hero
   ================================================================== */

.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100svh;
  max-width: var(--max);
  margin: 0 auto;
  padding: 8rem var(--gutter) 4rem;
}

h1 {
  max-width: 14ch;
  margin: 1.5rem 0 0;
  font-size: clamp(3rem, 9vw, 8.5rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

h1 em {
  color: var(--gold);
}

.hero-sub {
  max-width: 38rem;
  margin: 2rem 0 2.5rem;
  font-size: clamp(1.2rem, 1vw + 1rem, 1.5rem);
  line-height: 1.5;
  color: var(--taupe);
}

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

/* ==================================================================
   9. Principles ribbon
   ================================================================== */

.ribbon {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.ribbon ul {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--line);
  border-block: 1px solid var(--line);
}

@media (min-width: 600px) {
  .ribbon ul {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .ribbon ul {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ribbon li {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  padding: 1.75rem 1.5rem;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.7;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
}

.ribbon-index {
  color: var(--gold);
}

.ribbon-title {
  font-size: 0.78rem;
  letter-spacing: 0.26em;
  color: var(--cream);
}

/* ==================================================================
   10. Doctrine (split layout)
   ================================================================== */

.doctrine-grid {
  display: grid;
  gap: clamp(3rem, 6vw, 6rem);
}

@media (min-width: 960px) {
  .doctrine-grid {
    grid-template-columns: 7fr 5fr;
  }
}

.doctrine-prose p {
  margin: 0 0 1.5em;
  font-size: clamp(1.25rem, 1vw + 1rem, 1.6rem);
  line-height: 1.55;
}

.doctrine-quote {
  position: relative;
  margin: 0 0 3.5rem;
  padding: 2rem 0 2rem 2rem;
  border-left: 2px solid var(--wine-bright);
}

.doctrine-quote::before {
  content: "\201C";
  position: absolute;
  top: -1.5rem;
  left: 1.25rem;
  font-size: 6rem;
  line-height: 1;
  color: var(--wine-bright);
  opacity: 0.5;
}

.doctrine-quote p {
  position: relative;
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  font-style: italic;
  line-height: 1.2;
}

.doctrine-quote footer {
  margin-top: 1.25rem;
  color: var(--ash);
}

.link-list-title {
  margin-bottom: 1rem;
}

/* Hover rows: lighter background + gold left border. */
.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.link-list li {
  border-bottom: 1px solid var(--line);
}

.link-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1rem;
  border-left: 2px solid transparent;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.6;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--taupe);
  transition:
    background-color 0.35s ease,
    border-color 0.35s ease,
    color 0.35s ease;
}

.link-list a:hover,
.link-list a:focus-visible {
  background: var(--bg-hover);
  border-left-color: var(--gold);
  color: var(--cream);
}

.link-list a span {
  transition: transform 0.35s var(--ease);
}

.link-list a:hover span {
  transform: translateX(4px);
}

/* ==================================================================
   11. Capabilities (accordion cards)
   Open state comes from aria-expanded on .card-toggle (main.js).
   The panel animates via grid-template-rows 0fr -> 1fr. Without JS
   every panel stays open, so no content is lost.
   ================================================================== */

.cards {
  display: grid;
  align-items: start;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 700px) {
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: rgba(12, 8, 8, 0.85);
  border: 1px solid var(--line);
  transition:
    background-color 0.35s ease,
    box-shadow 0.35s ease;
}

.card:hover,
.card:focus-within {
  background: var(--bg-hover);
  box-shadow: inset 3px 0 0 var(--wine-bright);
}

.card-heading {
  margin: 0;
  font-weight: inherit;
}

.card-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  width: 100%;
  padding: 1.75rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.card-index {
  padding-top: 0.55rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.card-title {
  display: block;
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.15;
}

.card-tag {
  display: block;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ash);
}

/* The + icon: two 1px bars, rotated 135deg into an x when open. */
.card-icon {
  position: relative;
  width: 18px;
  height: 18px;
  margin-top: 0.5rem;
  transition: transform 0.5s var(--ease);
}

.card-icon::before,
.card-icon::after {
  content: "";
  position: absolute;
  background: var(--gold);
}

.card-icon::before {
  inset: 50% 0 auto;
  height: 1px;
}

.card-icon::after {
  inset: 0 auto 0 50%;
  width: 1px;
}

[aria-expanded="true"] .card-icon {
  transform: rotate(135deg);
}

.card-body {
  display: grid;
  grid-template-rows: 1fr;
}

.js .card-body {
  grid-template-rows: 0fr;
  visibility: hidden;
  transition:
    grid-template-rows 0.55s var(--ease),
    visibility 0s linear 0.55s;
}

.js .card:has([aria-expanded="true"]) .card-body {
  grid-template-rows: 1fr;
  visibility: visible;
  transition:
    grid-template-rows 0.55s var(--ease),
    visibility 0s;
}

.card-inner {
  overflow: hidden;
}

.card-inner p {
  margin: 0;
  padding: 0 1.75rem 1.75rem;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--taupe);
}

/* ==================================================================
   12. Test library (dense tile grid)
   ================================================================== */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

@media (min-width: 520px) {
  .tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 760px) {
  .tiles {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1000px) {
  .tiles {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 1240px) {
  .tiles {
    grid-template-columns: repeat(7, 1fr);
  }
}

.tiles li {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  height: 100%;
  min-height: 8.5rem;
  padding: 1.25rem 1rem;
  text-decoration: none;
  transition:
    background-color 0.35s ease,
    box-shadow 0.35s ease;
}

.tile-title {
  font-size: 1.2rem;
  line-height: 1.15;
  color: var(--taupe);
  transition: color 0.35s ease;
}

.tile-sub {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ash);
  transition: color 0.35s ease;
}

a.tile:hover,
a.tile:focus-visible {
  background: var(--bg-hover);
  box-shadow:
    inset 0 0 28px rgba(178, 57, 60, 0.18),
    inset 0 0 0 1px rgba(196, 164, 74, 0.18);
}

a.tile:hover .tile-title,
a.tile:focus-visible .tile-title {
  color: var(--cream);
}

a.tile:hover .tile-sub,
a.tile:focus-visible .tile-sub {
  color: var(--gold);
}

/* ==================================================================
   13. Footer
   ================================================================== */

.footer {
  max-width: var(--max);
  margin: var(--section) auto 0;
  padding: 0 var(--gutter) 2.5rem;
}

.footer-main {
  display: grid;
  gap: 3rem;
  padding: clamp(3rem, 8vw, 6rem) 0;
  border-top: 1px solid var(--line);
}

@media (min-width: 900px) {
  .footer-main {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .footer-quote {
    justify-self: end;
    text-align: right;
  }
}

.footer-cta h2 {
  margin-bottom: 2.25rem;
}

.footer-quote {
  max-width: 26ch;
  margin: 0;
}

.footer-quote p {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
  font-style: italic;
  line-height: 1.25;
  color: var(--taupe);
}

.footer-quote footer {
  color: var(--ash);
}

.footer-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ash);
}

.footer-base a {
  text-decoration: none;
  color: var(--taupe);
}

.footer-base a:hover {
  color: var(--cream);
}

/* ==================================================================
   14. Reveal on scroll
   main.js adds .is-visible; --d (stagger) is set by main.js and
   --base delays the hero until the pre-loader clears.
   ================================================================== */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition:
      opacity 1s var(--ease) calc(var(--base, 0s) + var(--d, 0s)),
      transform 1s var(--ease) calc(var(--base, 0s) + var(--d, 0s));
  }

  .js .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* ==================================================================
   15. Reduced motion: remove all transitions and animations.
   ================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    animation-duration: 0s !important;
  }
}
