/* ===========================================================================
   Gabo Fragments Frame Lab — community gallery exhibit
   Aligned with Gabo Fragments Society (GFS) editorial prototype.
   Cobalt ink + cream paper. Anton (heavy condensed) + Inter typography.
   =========================================================================== */

:root {
  /* Primary brand colors (from GFS prototype) */
  --cobalt:        #1E3A6E;    /* PRIMARY — buttons, headlines, icons */
  --cobalt-deep:   #0F1F40;    /* darker variant — text strong */
  --cobalt-bright: #2E5BB0;    /* hover variant */
  --cream:         #F5F1E8;    /* aged paper background */
  --cream-2:       #EDE6D5;    /* slightly darker cream — section dividers */
  --bone:          #FFFCF5;    /* card / panel background */
  --ink:           #1A1A1A;    /* primary body text — near black, not pure */
  --ink-soft:      #555555;    /* secondary body text */
  --terracotta:    #C2543B;    /* accent — sparingly, for CTAs or callouts */
  --tile-blue:     #2A5BA0;    /* azulejo motif color */
  --tile-white:    #FAF6EC;    /* azulejo motif white */
  --line:          rgba(30, 58, 110, 0.15);
  --line-strong:   rgba(30, 58, 110, 0.35);
  --shadow:        rgba(15, 31, 64, 0.18);

  /* Typography */
  --font-display: 'Anton', 'Bebas Neue', Impact, sans-serif;  /* heavy condensed */
  --font-body:    'Inter', system-ui, sans-serif;             /* body */
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;  /* token IDs */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background-color: var(--cream);
  /* Very faint tile motif — repeating SVG at low opacity */
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><g fill='none' stroke='%231E3A6E' stroke-width='1' opacity='0.08'><rect x='10' y='10' width='80' height='80' rx='2'/><rect x='110' y='10' width='80' height='80' rx='2'/><rect x='10' y='110' width='80' height='80' rx='2'/><rect x='110' y='110' width='80' height='80' rx='2'/><path d='M50 30 L70 50 L50 70 L30 50 Z' opacity='0.6'/><path d='M150 30 L170 50 L150 70 L130 50 Z' opacity='0.6'/><path d='M50 130 L70 150 L50 170 L30 150 Z' opacity='0.6'/><path d='M150 130 L170 150 L150 170 L130 150 Z' opacity='0.6'/><circle cx='50' cy='50' r='6' opacity='0.5'/><circle cx='150' cy='50' r='6' opacity='0.5'/><circle cx='50' cy='150' r='6' opacity='0.5'/><circle cx='150' cy='150' r='6' opacity='0.5'/></g></svg>");
  background-size: 200px 200px;
  background-repeat: repeat;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

.mono { font-family: var(--font-mono); }

/* ===== Nav bar ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.nav-logo {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--cobalt);
}
.nav-logo .logo-block {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: var(--cobalt);
  color: #fff;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.02em;
  border-radius: 2px;
}
.nav-logo .logo-text {
  font-size: 22px;
  color: var(--cobalt-deep);
}
.nav-links {
  display: inline-flex; align-items: center; gap: 28px;
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cobalt-deep);
  transition: color 0.15s;
}
.brand-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  vertical-align: middle;
  /* Brand-color SVGs (opensea.svg + x.svg + apechain.svg) — no fill override */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}
.footer-col li a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-links a:hover { color: var(--cobalt-bright); }
.nav-links .nav-cta {
  padding: 10px 18px;
  background: var(--cobalt);
  color: #fff;
  border-radius: 2px;
  transition: background 0.15s;
}
.nav-links .nav-cta:hover { background: var(--cobalt-bright); color: #fff; }
@media (max-width: 720px) {
  .nav { padding: 12px 18px; }
  .nav-links { gap: 14px; }
  .nav-links a:not(.nav-cta) { display: none; }
}

/* ===== Page container ===== */
.page {
  position: relative; z-index: 1;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 28px 0;
}

/* ===== SPLIT HERO — tagline + tool side-by-side (above the fold) ===== */
.hero,
.split-hero {
  padding: 28px 0 36px;
  border-bottom: 1px solid var(--line);
}
.split-hero {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 36px;
  align-items: center;
}
.split-hero-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 480px;
}
.split-hero-right {
  /* contains the card-stage */
  min-width: 0;
}

.hero-headline {
  font-family: var(--font-display);
  font-size: clamp(40px, 5.6vw, 72px);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: var(--cobalt-deep);
  margin: 0;
  text-transform: uppercase;
}
.hero-headline .accent { color: var(--cobalt); }
.hero-sub {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 480px;
  margin: 0 0 6px;
}
.hero-badge {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border: 1.5px solid var(--cobalt);
  border-radius: 2px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cobalt);
  background: transparent;
}
.hero-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cobalt);
}

/* Tablet — keep split but tighter */
@media (max-width: 1100px) {
  .split-hero { grid-template-columns: 1fr 1fr; gap: 24px; }
}

/* Mobile — stack vertically, renderer FIRST so user sees artwork immediately */
@media (max-width: 768px) {
  .split-hero {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .split-hero-right { order: 1; }   /* renderer on top */
  .split-hero-left  { order: 2; }   /* controls below */
  .hero-headline { font-size: clamp(36px, 9vw, 56px); }
}

/* ===== FRAME LAB section ===== */
.lab {
  padding: 56px 0;
  border-bottom: 1px solid var(--line);
}
.section-head {
  margin-bottom: 32px;
}
.section-eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--cobalt);
  margin: 0 0 8px;
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.0;
  letter-spacing: 0.01em;
  color: var(--cobalt-deep);
  margin: 0;
  text-transform: uppercase;
}

.lab-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
@media (max-width: 980px) {
  .lab-grid { grid-template-columns: 1fr; }
}

/* ===== Controls panel ===== */
.panel {
  position: relative;
  background: var(--bone);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 24px;
}

.panel-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head .num {
  width: 28px; height: 28px;
  background: var(--cobalt); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  border-radius: 2px;
}
.panel-head .panel-head-label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cobalt-deep);
}

.field { margin-bottom: 0; }
.field:last-child { margin-bottom: 0; }
.split-hero-left .field { margin-bottom: 4px; }
.field label {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.input {
  width: 100%; padding: 14px 16px;
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--cobalt-deep);
  appearance: none; outline: none;
  letter-spacing: 0.06em;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(30, 58, 110, 0.18);
}
.input::placeholder { color: var(--ink-soft); opacity: 0.55; }

.token-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch;
}
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; min-width: 110px; height: 44px;
  background: #fff; color: var(--cobalt);
  border: 1.5px solid var(--line-strong); border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0 18px;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn-icon:hover {
  background: var(--cobalt);
  color: #fff;
  border-color: var(--cobalt);
}
.btn-icon svg { width: 22px; height: 22px; display: block; }

/* Big CTA — Frame It */
.btn-cta {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 18px 24px;
  background: var(--cobalt);
  color: #fff;
  border: 1.5px solid var(--cobalt);
  border-radius: 2px;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.btn-cta:hover {
  background: var(--cobalt-bright);
  transform: translateY(-1px);
}
.btn-cta:active { transform: translateY(0); }
.btn-cta:disabled {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
  cursor: not-allowed;
}

.dock-error {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(194, 84, 59, 0.10);
  border: 1px solid var(--terracotta);
  border-left: 3px solid var(--terracotta);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cobalt-deep);
}
.dock-error[hidden] { display: none; }

.tier-info {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.tier-label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.tier-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.tier-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}
.tier-pill .tier-k {
  font-weight: 800;
  color: var(--cobalt);
}

/* ===== Stage — gallery card preview ===== */
.card-stage {
  perspective: 1600px;
  padding: 18px;
  display: flex; align-items: center; justify-content: center;
  /* Sized to fit above the fold on 1366x768 — viewport height aware */
  min-height: min(620px, calc(100vh - 200px));
  position: relative;
  background: var(--cream-2);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
}
.stage-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 252, 245, 0.7) 0%, rgba(255, 252, 245, 0) 55%),
    linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  border-radius: 4px;
  z-index: 0;
}
.slab-wrap {
  position: relative; z-index: 1;
  width: min(380px, 88%);
  aspect-ratio: 1200 / 1680;
}
.slab-canvas {
  display: block;
  width: 100%; height: 100%;
  border-radius: 2px;
  filter: drop-shadow(0 12px 24px rgba(15, 31, 64, 0.20));
}

.stage-loading {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  background: rgba(245, 241, 232, 0.75);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.stage-loading[hidden] { display: none; }
.loading-bubble {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  background: var(--cobalt);
  border-radius: 2px;
  padding: 10px 18px;
  animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.stage-toast {
  position: absolute;
  bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 4;
  background: var(--cobalt-deep); color: var(--cream);
  padding: 10px 18px; border-radius: 2px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--cobalt);
}
.stage-toast[hidden] { display: none; }

/* ===== Export row ===== */
.export-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 6px;
}
.split-hero-left .export-row { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 1100px) {
  .split-hero-left .export-row { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .export-row { grid-template-columns: repeat(2, 1fr); }
}
.export-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 12px;
  background: transparent;
  border: 1.5px solid var(--cobalt);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--cobalt);
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.export-btn:hover {
  background: var(--cobalt);
  color: #fff;
  transform: translateY(-1px);
}
.export-btn:active { transform: translateY(0); }
.export-btn:disabled {
  opacity: 0.4; cursor: not-allowed; transform: none;
}
.export-btn .ico {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
}
.export-btn .meta {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* ===== FRAGMENT HIERARCHY ===== */
.hierarchy {
  padding: 64px 0;
  border-bottom: 1px solid var(--line);
}
.hierarchy-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  margin: 36px 0 28px;
}
@media (max-width: 820px) {
  .hierarchy-grid { grid-template-columns: 1fr; }
}
.tier-card {
  background: var(--bone);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 28px 24px;
  text-align: left;
}
.tier-card .num {
  font-family: var(--font-display);
  font-size: clamp(64px, 8vw, 88px);
  line-height: 1.0;
  color: var(--cobalt);
  margin: 0 0 4px;
}
.tier-card .name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--cobalt-deep);
  text-transform: uppercase;
  margin: 0 0 6px;
}
.tier-card .sub {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin: 0 0 16px;
}
.tier-card .grid-vis {
  display: grid;
  gap: 0;                                        /* tight grid for clean slicing */
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  background-color: var(--bone);
  background-image: url('genesis-bg.webp');      /* full artwork visible everywhere */
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  overflow: hidden;
}
/* Cream wash heavily fades the artwork in the grid — default cells let
   this faded version show through. Active cells (higher z-index) bypass
   this overlay and render the artwork at full brightness. */
.tier-card .grid-vis::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(245, 241, 232, 0.85);
  z-index: 1;
  pointer-events: none;
}
.tier-card.t1 .grid-vis { grid-template-columns: repeat(3, 1fr); }
.tier-card.t2 .grid-vis { grid-template-columns: repeat(9, 1fr); }
.tier-card.t3 .grid-vis { grid-template-columns: repeat(30, 1fr); }
.tier-card .grid-vis span {
  position: relative;
  z-index: 2;                                    /* above overlay, but transparent */
  background-color: transparent;                 /* see faded artwork through */
  aspect-ratio: 1 / 1;
  transition: background-color 0.3s ease;
}
/* Active cells = window with FULL-brightness artwork slice. They sit
   above the cream overlay, blocking it. Their bg-image is the same
   genesis, sized + positioned per-cell so the slice aligns with the
   grid's underlying faded artwork — creating a 'spotlight' effect. */
.tier-card .grid-vis span.active {
  z-index: 3;
  background-color: var(--bone);                 /* fallback while image paints */
  background-image: url('genesis-bg.webp');
  background-repeat: no-repeat;
}

.hierarchy-caption {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 820px;
  margin: 0;
}

/* ===========================================================================
   REASSEMBLE THE GENESIS — sliding puzzle
   =========================================================================== */
.puzzle-section {
  padding: 64px 0;
  border-bottom: 1px solid var(--line);
}
.puzzle-sub {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 620px;
  margin: -18px 0 28px;
}

/* ----- Difficulty selector ----- */
.puzzle-difficulty {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}
.puzzle-diff-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 18px;
  min-width: 120px;
  background: transparent;
  border: 1.5px solid var(--cobalt);
  border-radius: 2px;
  cursor: pointer;
  color: var(--cobalt);
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.puzzle-diff-btn:hover { transform: translateY(-1px); }
.puzzle-diff-btn .diff-main {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  line-height: 1;
}
.puzzle-diff-btn .diff-sub {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  opacity: 0.85;
}
.puzzle-diff-btn.active {
  background: var(--cobalt);
  color: #fff;
  border-color: var(--cobalt);
}

/* ----- Layout: board + side panel ----- */
.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
@media (max-width: 820px) {
  .puzzle-layout { grid-template-columns: 1fr; gap: 22px; }
}

/* ----- Board ----- */
.puzzle-board-wrap {
  position: relative;
  width: 100%;
  max-width: 440px;
}
.puzzle-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: var(--bone);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  /* tiles sit slightly inside so the empty slot reads as bone, not a hole */
  overflow: hidden;
  touch-action: manipulation;
}
/* Reference (hint) toggle — full Genesis faint behind the tiles */
.puzzle-board.show-reference::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('genesis-bg.webp');
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  z-index: 0;
  pointer-events: none;
}

/* ----- Tiles — absolutely positioned, animated via transform ----- */
.puzzle-tile {
  position: absolute;
  top: 0;
  left: 0;
  /* one cell minus a small gap; transform places it at its grid position */
  width: calc(100% / var(--puzzle-n, 3));
  height: calc(100% / var(--puzzle-n, 3));
  margin: 0;
  padding: 0;
  border: 1px solid var(--cobalt);
  border-radius: 3px;
  background-color: var(--cream);
  background-repeat: no-repeat;
  background-clip: padding-box;
  /* slight inset via box-shadow ring keeps a visible seam between tiles */
  box-shadow: inset 0 0 0 1px rgba(255, 252, 245, 0.5);
  cursor: pointer;
  z-index: 1;
  /* Smooth slide — transform animates between grid cells. */
  transition: transform 0.16s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.puzzle-tile:hover { filter: brightness(1.06); }
.puzzle-tile:focus-visible {
  outline: 2px solid var(--cobalt-bright);
  outline-offset: -2px;
  z-index: 2;
}
@media (prefers-reduced-motion: reduce) {
  .puzzle-tile { transition: filter 0.15s ease; }
}

/* Non-slidable feedback — the transform is already used for positioning, so
   the "can't move" cue is a brief brightness/saturation pulse, not a wiggle
   (a translate-based shake would fight the layout transform). */
.puzzle-tile.shake {
  animation: puzzleShakePulse 0.32s ease;
}
@keyframes puzzleShakePulse {
  0%, 100% { filter: none; }
  30%      { filter: brightness(0.9) saturate(1.2); }
  60%      { filter: brightness(1.08); }
}

/* ----- Win overlay ----- */
.puzzle-win {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(245, 241, 232, 0.78);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.puzzle-win.show { opacity: 1; visibility: visible; }
.puzzle-win-panel {
  background: var(--bone);
  border: 1px solid var(--cobalt);
  border-radius: 4px;
  padding: 26px 28px;
  text-align: center;
  box-shadow: 0 12px 30px var(--shadow);
  max-width: 90%;
}
.puzzle-win-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--cobalt-deep);
  margin: 0 0 8px;
}
.puzzle-win-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--cobalt);
  margin: 0 0 20px;
}
.puzzle-win-stats .dot { opacity: 0.5; }
.puzzle-win-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ----- Stats bar ----- */
.puzzle-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}
.puzzle-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bone);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
.puzzle-stat-label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.puzzle-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--cobalt-deep);
  line-height: 1;
}

/* ----- Controls ----- */
.puzzle-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.puzzle-btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 20px;
  border-radius: 2px;
  cursor: pointer;
  border: 1.5px solid var(--cobalt);
  transition: background 0.15s, color 0.15s, transform 0.12s, border-color 0.15s;
}
.puzzle-btn:hover { transform: translateY(-1px); }
.puzzle-btn:active { transform: translateY(0); }
.puzzle-btn-primary {
  background: var(--cobalt);
  color: #fff;
}
.puzzle-btn-primary:hover { background: var(--cobalt-bright); border-color: var(--cobalt-bright); }
.puzzle-btn-toggle,
.puzzle-btn-ghost {
  background: transparent;
  color: var(--cobalt);
}
.puzzle-btn-toggle:hover,
.puzzle-btn-ghost:hover { background: var(--cobalt); color: #fff; }
.puzzle-btn-toggle.active {
  background: var(--cobalt);
  color: #fff;
}
.puzzle-btn-share {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}
.puzzle-btn-share:hover {
  background: #a8432d;
  border-color: #a8432d;
}
.puzzle-hint {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 420px;
  margin: 0;
}

@media (max-width: 820px) {
  /* On mobile the board comes first, side panel below */
  .puzzle-board-wrap { max-width: 92vw; margin: 0 auto; }
  .puzzle-side { width: 100%; }
}

/* ===== FROM LISBON TO THE CHAIN — timeline (horizontal scroll-snap) ===== */
.timeline-section {
  padding: 56px 0 64px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.timeline {
  display: flex;
  align-items: stretch;
  gap: 24px;
  margin-top: 36px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 20px;
  padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
  /* subtle right-fade hint that more content is scrollable */
  mask-image: linear-gradient(to right, #000 0%, #000 92%, rgba(0,0,0,0.6) 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 92%, rgba(0,0,0,0.6) 100%);
}
.timeline::-webkit-scrollbar { height: 6px; }
.timeline::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}
.timeline-step {
  flex: 0 0 280px;
  scroll-snap-align: start;
  background: var(--bone);
  border: 1px solid var(--line);
  padding: 22px 18px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
@media (max-width: 768px) {
  .timeline-step { flex: 0 0 75vw; }
}
/* swipe-hint on mobile/tablet — subtle pulse arrow at the right edge */
.timeline-hint {
  display: none;
  position: absolute;
  right: 8px;
  bottom: 80px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cobalt);
  background: var(--bone);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 6px 10px;
  pointer-events: none;
  animation: hintPulse 2.2s ease-in-out infinite;
}
@media (max-width: 980px) {
  .timeline-hint { display: inline-flex; }
}
@keyframes hintPulse {
  0%, 100% { transform: translateX(0); opacity: 0.7; }
  50%      { transform: translateX(6px); opacity: 1; }
}
.timeline-step .step-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--cobalt);
}
.timeline-step .step-icon {
  color: var(--cobalt);
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
}
.timeline-step .step-icon svg {
  width: 100%; height: 100%; fill: currentColor;
}
.timeline-step .step-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cobalt-deep);
  line-height: 1.1;
  margin: 0;
}
.timeline-step .step-desc {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}
.timeline-arrow {
  /* Hidden — horizontal scroll-snap UX makes inline arrows redundant.
     Direction is conveyed by the swipe-hint + scroll affordance instead. */
  display: none;
}

/* ===== Footer ===== */
.footer {
  margin-top: 0;
  padding: 56px 0 32px;
  background: var(--cobalt-deep);
  color: var(--cream);
  position: relative;
  margin-left: -28px;
  margin-right: -28px;
  padding-left: 28px;
  padding-right: 28px;
}
.footer-inner {
  max-width: 1380px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 48px;
}
@media (max-width: 820px) {
  .footer-inner { grid-template-columns: 1fr; }
}
.footer-brand .logo-block {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: var(--cream);
  color: var(--cobalt-deep);
  font-family: var(--font-display);
  font-size: 26px;
  border-radius: 2px;
  margin-bottom: 14px;
}
.footer-brand .tag {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--cream);
  text-transform: uppercase;
  line-height: 1.1;
  margin: 0;
}
.footer-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
@media (max-width: 640px) {
  .footer-cols { grid-template-columns: 1fr; }
}
.footer-col h4 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.6;
  margin: 0 0 14px;
}
.footer-col ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.footer-col a {
  color: var(--cream);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}
.footer-col a:hover { color: #fff; }
.footer-col .muted { color: var(--cream); opacity: 0.6; cursor: default; }
.footer-disclaimer {
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.6;
  color: var(--cream);
  opacity: 0.7;
}
.footer-disclaimer strong { color: var(--cream); opacity: 1; }
.footer-bottom {
  max-width: 1380px;
  margin: 36px auto 0;
  padding-top: 22px;
  border-top: 1px solid rgba(245, 241, 232, 0.18);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.7;
}
@media (max-width: 640px) {
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .loading-bubble { animation: none !important; }
}

/* ===== Mobile-first responsive (>=360px) ===== */
@media (max-width: 480px) {
  .page { padding: 0 16px; }
  .split-hero, .hero { padding: 20px 0 28px; }
  .hierarchy, .timeline-section { padding: 40px 0; }
  .panel { padding: 18px; }
  .card-stage { min-height: 460px; padding: 12px; }
  .slab-wrap { width: min(340px, 92%); }
  .btn-cta { font-size: 20px; padding: 16px 18px; }
  .nav { padding: 10px 16px; }
  .footer { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .export-row { grid-template-columns: repeat(2, 1fr); }
}
