/* ==========================================================================
   HEIMDALL — shared design system
   The four forges: forge (steel) · bifrost (bridge) · hamr (iron) · gard (bronze)

   A restrained Norse-forge identity on one dark family. Norse shows up in
   name, small carved sigils, and per-page metal accents — never in noise.

   Usage:
     <html lang="en" data-metal="steel|iron|bronze|bridge">
     <link rel="stylesheet" href="/_system/style.css">
     <script src="/_system/index.js" defer></script>

   Standalone sites may ignore this system entirely and bring their own
   stylesheets; the default for new pages is this one.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */
:root {
  /* base — warm charcoal, layered, not pure black */
  --bg-0: #0B0D11;
  --bg-1: #10131A;
  --bg-2: #161B24;
  --line: #212938;
  --line-2: #2E3950;
  --ink: #E9E7E2;
  --ink-2: #A9AFBA;
  --ink-3: #767F8E;

  --font-display: 'Cinzel', 'Alegreya Sans', Georgia, serif;
  --font-body: 'Alegreya Sans', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Fragment Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* the metal of this page (defaults to steel) */
  --metal: #8FB3C6;
  --metal-2: #B9955E;              /* secondary metal — the far end of the bridge */
  --metal-ink: #0B0D11;            /* text on filled metal */

  --radius: 10px;
  --shadow-lift: 0 14px 34px rgba(3, 5, 9, 0.4);
  --ease: cubic-bezier(0.22, 0.61, 0.21, 1);
}

:root[data-metal='steel']  { --metal: #8FB3C6; }
:root[data-metal='iron']   { --metal: #C88A4E; }
:root[data-metal='bronze'] { --metal: #B9955E; }
:root[data-metal='bridge'] { --metal: #9A9FD8; --metal-2: #8FB3C6; }

/* --- base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: color-mix(in oklab, var(--metal) 32%, transparent);
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--metal);
  outline-offset: 3px;
  border-radius: 4px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- atmosphere (parallax layer + grain) -------------------------------- */
/* .fx sits behind the page: a soft forge-glow up top, an ember low right,
   and the page's own sigil ghosted large. index.js drifts it a few
   percent against scroll — quiet, never showy. */
.fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(52rem 26rem at 50% -8rem,
      color-mix(in oklab, var(--metal) 9%, transparent), transparent 70%),
    radial-gradient(42rem 24rem at 88% 118%,
      color-mix(in oklab, var(--metal-2) 5%, transparent), transparent 72%);
  will-change: transform;
}
.fx-glyph {
  position: absolute;
  top: 16%;
  right: -70px;
  width: min(380px, 92vw);
  height: auto;
  color: var(--metal);
  opacity: 0.045;
  will-change: transform;
}
/* fine grain over everything — the page reads as forged, not flat */
.grain {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* --- chrome ------------------------------------------------------------- */
.topbar, main, .footer { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1.25rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.wordmark .sigil { width: 17px; height: 17px; }
.topnav {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
}
.topnav a {
  color: var(--ink-3);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.topnav a:hover { color: var(--metal); }

.footer {
  border-top: 1px solid var(--line);
  padding: 1.6rem clamp(1.25rem, 4vw, 2.5rem);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.footer a { color: var(--ink-3); text-decoration: none; transition: color 0.2s var(--ease); }
.footer a:hover { color: var(--metal); }

/* --- type --------------------------------------------------------------- */
.sigil {
  color: var(--metal);
  flex: none;
}
.kicker {
  margin: 0 0 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.display {
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 6vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.lede {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--ink-2);
  font-size: 1.06rem;
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
  letter-spacing: 0.02em;
}

/* --- hero --------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: clamp(3.5rem, 9vw, 5.5rem) clamp(1.25rem, 4vw, 2.5rem) clamp(2.5rem, 6vw, 4rem);
}
.hero .hero-sigil {
  width: 30px;
  height: 30px;
  margin-bottom: 1.4rem;
  opacity: 0.9;
}
.hero-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hero-meta .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--metal);
}

/* --- groups & cards ----------------------------------------------------- */
.group {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem) clamp(2.5rem, 6vw, 4rem);
}
.group-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1.3rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.group-label::before {
  content: '';
  width: 20px;
  height: 1px;
  background: var(--metal);
  opacity: 0.9;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: 1.1rem;
}
.card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-2), color-mix(in oklab, var(--bg-2) 70%, #05070B));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.35rem;
}
a.card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.28s var(--ease), border-color 0.28s var(--ease), box-shadow 0.28s var(--ease);
}
a.card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in oklab, var(--metal) 45%, var(--line));
  box-shadow: var(--shadow-lift);
}
.card .card-sigil {
  width: 20px;
  height: 20px;
  margin-bottom: 1rem;
}
.card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.card p {
  flex: 1;
  margin: 0;
  color: var(--ink-2);
  font-size: 0.95rem;
  line-height: 1.6;
}
.card .host {
  margin-top: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.card .tag {
  align-self: flex-start;
  margin-top: 1rem;
  padding: 0.28rem 0.72rem 0.24rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: border-color 0.28s var(--ease), color 0.28s var(--ease);
}
a.card:hover .tag {
  border-color: color-mix(in oklab, var(--metal) 50%, var(--line-2));
  color: var(--ink);
}

/* --- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.72rem 1.35rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease),
              border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn-primary {
  background: var(--metal);
  border: 1px solid transparent;
  color: var(--metal-ink);
}
.btn-primary:hover {
  background: color-mix(in oklab, var(--metal) 86%, white);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px color-mix(in oklab, var(--metal) 22%, transparent);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink);
}
.btn-ghost:hover {
  border-color: var(--metal);
  transform: translateY(-1px);
}

/* --- sign-in block (bifrost) -------------------------------------------- */
.signin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  margin-top: 2.4rem;
}
.signin-note {
  max-width: 27rem;
  margin: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  line-height: 1.8;
  color: var(--ink-3);
}

/* --- gate (hamr / gard) --------------------------------------------------- */
.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem) clamp(3rem, 7vw, 4.5rem);
}
.gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  max-width: 27rem;
  padding: 2.4rem 2.2rem 2.2rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-2), color-mix(in oklab, var(--bg-2) 70%, #05070B));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
}
.gate-card .kicker { margin-bottom: 0.4rem; }
.gate-title {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}
.gate-card p {
  margin: 0;
  max-width: 21rem;
  color: var(--ink-2);
  font-size: 0.95rem;
}
.gate-card .btn { margin-top: 0.9rem; }
.gate-note {
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  line-height: 1.8;
  color: var(--ink-3);
}

/* --- hammer-strike divider ------------------------------------------------ */
.strike {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
}
.strike::before, .strike::after {
  content: '';
  height: 1px;
  flex: 1;
}
.strike::before { background: linear-gradient(90deg, transparent, var(--line-2)); }
.strike::after  { background: linear-gradient(90deg, var(--line-2), transparent); }
.strike .dot {
  flex: none;
  width: 5px;
  height: 5px;
  background: var(--metal);
  transform: rotate(45deg);
}

/* --- the bridge (bifrost) -------------------------------------------------- */
.bridge-wrap {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 0.5rem;
}
.bridge {
  display: block;
  width: min(560px, 82vw);
  height: auto;
}
.bridge path { fill: none; }
.bridge .ground { stroke: var(--line-2); stroke-width: 1; }
.bridge .arc { stroke-width: 2; stroke-linecap: round; }
.bridge .arc-main { stroke: var(--metal); }
.bridge .arc-a { stroke: color-mix(in oklab, var(--metal-2) 55%, transparent); stroke-width: 1.4; }
.bridge .arc-b { stroke: color-mix(in oklab, var(--metal) 32%, transparent); stroke-width: 1.4; }

/* the bridge draws itself on load (only when JS has tagged <html class="js">) */
html.js .bridge path { stroke-dasharray: 1; stroke-dashoffset: 1; }
html.js .bridge .ground { animation: bridge-fade 0.9s ease 0.1s both; }
html.js .bridge .arc-main { animation: bridge-draw 1.5s var(--ease) 0.15s forwards; }
html.js .bridge .arc-a { animation: bridge-draw 1.5s var(--ease) 0.4s forwards; }
html.js .bridge .arc-b { animation: bridge-draw 1.5s var(--ease) 0.6s forwards; }
@keyframes bridge-draw { to { stroke-dashoffset: 0; } }
@keyframes bridge-fade { from { opacity: 0; } to { opacity: 1; } }

/* --- reveals ---------------------------------------------------------------- */
.reveal { opacity: 1; }
html.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.65s var(--ease), transform 0.65s var(--ease);
  transition-delay: calc(var(--i, 0) * 80ms);
}
html.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

/* --- reduced motion / stillness --------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  html.js .bridge path { animation: none; stroke-dashoffset: 0; }
  .fx, .fx-glyph { transform: none !important; }
  a.card:hover, .btn:hover { transform: none; }
}
