@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Cinzel+Decorative:wght@400;700&family=IM+Fell+English:ital@0;1&family=UnifrakturMaguntia&display=swap');

:root {
  /* Victorian Palette */
  --bg: #2c1e0f;
  --bg-glow: #3d2a10;
  --surface: #f5edd8;
  --ink: #1a0f00;
  --muted: #5c3d1e;
  --line: #8b6914;
  --gold: #c9a227;
  --gold-light: #e8c84a;
  --gold-dark: #8b6914;
  --gold-pale: #f0dfa0;
  --crimson: #7a1520;
  --crimson-soft: #f5d5d8;
  --navy: #0f1e3d;
  --navy-soft: #d0d8f0;
  --parchment: #f5edd8;
  --parchment-dark: #e0ceaa;
  --card-shadow: 0 18px 48px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(201, 162, 39, 0.3), inset 0 1px 0 rgba(201, 162, 39, 0.15);

  /* Author tones mapped to Victorian suits */
  --sofia: #1a3a2a;
  --sofia-soft: #d5e8dc;
  --quinn: #4a1020;
  --quinn-soft: #f0d8dc;

  /* TCG specific */
  --accent: #c9a227;
  --accent-soft: #f5edd8;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'IM Fell English', Georgia, 'Times New Roman', serif;
  color: var(--parchment);
  background-color: var(--bg);
  background:
    radial-gradient(ellipse at 50% 0%, #4a2e10 0%, transparent 55%),
    radial-gradient(ellipse at 0% 100%, #1a2030 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, #301018 0%, transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(201, 162, 39, 0.02) 2px,
      rgba(201, 162, 39, 0.02) 4px
    ),
    linear-gradient(160deg, #2c1e0f, #1e1628);
}

/* ─── Layout ─────────────────────────────────────────────── */

.wrap {
  width: min(960px, 92vw);
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

/* ─── Header ─────────────────────────────────────────────── */

.site-head {
  border-bottom: 1px solid var(--gold-dark);
  padding-bottom: 0.85rem;
  margin-bottom: 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.site-head::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.5;
}

.brand {
  text-decoration: none;
  color: var(--gold);
  font-family: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 0 20px rgba(201, 162, 39, 0.4);
}

a {
  color: var(--gold);
}

.site-head nav a {
  border: 1px solid var(--gold-dark);
  background: transparent;
  color: var(--gold-pale);
  border-radius: 0;
  text-decoration: none;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.42rem 1rem;
  position: relative;
  clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
}

.site-head nav a:hover {
  background: rgba(201, 162, 39, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}

/* ─── Typography ─────────────────────────────────────────── */

h1, h2, h3 {
  font-family: 'Cinzel', Georgia, serif;
  letter-spacing: 0.02em;
}

.swipe-hero h1 {
  margin: 0.2rem 0 0.55rem;
  line-height: 1.1;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--gold);
  text-shadow: 0 0 30px rgba(201, 162, 39, 0.35);
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 600;
  color: var(--gold-dark);
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
}

.lede {
  max-width: 60ch;
  color: rgba(240, 223, 160, 0.65);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ─── About page ─────────────────────────────────────────── */

.about-hero {
  margin-bottom: 1.1rem;
}

.about-panel {
  border: 1px solid var(--gold-dark);
  background: linear-gradient(170deg, rgba(42, 28, 14, 0.95), rgba(26, 18, 8, 0.95));
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.14);
  padding: clamp(0.9rem, 2.5vw, 1.2rem);
  margin: 0 0 0.9rem;
}

.about-panel h2 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  color: var(--gold-pale);
}

.about-panel h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--gold-pale);
}

.about-panel p {
  margin: 0.45rem 0;
  color: rgba(240, 223, 160, 0.9);
  line-height: 1.62;
}

.about-panel ul,
.about-panel ol {
  margin: 0.5rem 0;
  padding-left: 1.15rem;
}

.about-panel li {
  margin: 0.3rem 0;
  color: rgba(240, 223, 160, 0.9);
  line-height: 1.55;
}

.about-intro {
  color: rgba(240, 223, 160, 0.7);
  font-style: italic;
}

.stack-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.6rem;
}

.stack-card {
  border: 1px solid var(--gold-dark);
  padding: 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.12);
}

.stack-card ul {
  margin: 0.25rem 0 0;
}

.stack-card.tone-sofia {
  background: linear-gradient(170deg, rgba(14, 34, 24, 0.92), rgba(7, 21, 16, 0.92));
  border-color: #2a6040;
}

.stack-card.tone-sofia h3,
.stack-card.tone-sofia li {
  color: #d8f0e0;
}

.stack-card.tone-quinn {
  background: linear-gradient(170deg, rgba(42, 10, 16, 0.92), rgba(24, 5, 8, 0.92));
  border-color: #7a1520;
}

.stack-card.tone-quinn h3,
.stack-card.tone-quinn li {
  color: #f5e0e2;
}

/* ─── Home screen scaffold ───────────────────────────────── */

.home-screen-body {
  overflow: hidden;
}

.home-screen {
  min-height: calc(100dvh - 96px);
  display: flex;
  flex-direction: column;
}

.swipe-shell {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.swipe-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--gold-dark);
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

.swipe-meta p {
  margin: 0;
}

/* ─── Controls ───────────────────────────────────────────── */

.sim-controls {
  display: flex;
  gap: 0.65rem;
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 120;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: blur(8px);
  transition: opacity 160ms ease;
}

.is-story-open .sim-controls {
  display: none !important;
}

.sim-btn {
  border: 1px solid var(--gold-dark);
  background: linear-gradient(180deg, rgba(201,162,39,0.12) 0%, rgba(139,105,20,0.08) 100%);
  color: var(--gold-pale);
  border-radius: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.48rem 1.1rem;
  cursor: pointer;
  clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
  transition: background 180ms ease, color 180ms ease;
  position: relative;
}

.sim-btn::before {
  content: '✦';
  margin-right: 0.45em;
  font-size: 0.6em;
  opacity: 0.7;
}

.sim-btn:hover {
  background: linear-gradient(180deg, rgba(201,162,39,0.28) 0%, rgba(139,105,20,0.2) 100%);
  color: var(--gold);
  border-color: var(--gold);
}

/* ─── Deck layout ────────────────────────────────────────── */

.deck-wrap {
  position: relative;
  width: min(100%, 360px);
  margin: auto;
}

.deck {
  position: relative;
  min-height: min(36vh, 280px);
  max-width: 360px;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
}

/* ─── Swipe card base ────────────────────────────────────── */

.swipe-card {
  position: absolute;
  inset: 0;
  border: 1px solid var(--gold-dark);
  background: #2a1c0e;
  border-radius: 0.45rem;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  will-change: transform;
  transition: transform 260ms ease, opacity 220ms ease;
  cursor: grab;
}

/* Outer ornate frame ring */
.swipe-card::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 0.2rem;
  pointer-events: none;
  z-index: 10;
}

/* Corner ornament pseudo-simulation via box-shadow on inner ring */
.swipe-card::after {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(201, 162, 39, 0.15);
  border-radius: 0;
  pointer-events: none;
  z-index: 10;
}

.swipe-card.is-top {
  cursor: grab;
}

.swipe-card.is-top:active {
  cursor: grabbing;
}

/* ─── Card internals ─────────────────────────────────────── */

.stack-count {
  margin: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gold-pale);
  font-weight: 600;
  opacity: 0.85;
}

.card-content {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: clamp(0.9rem, 2.5vw, 1.1rem);
  display: grid;
  align-content: start;
  gap: 0.6rem;
}

/* Parchment-style background texture overlay on card content */
.card-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 18px,
      rgba(255,255,255,0.012) 18px,
      rgba(255,255,255,0.012) 19px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 22px,
      rgba(255,255,255,0.008) 22px,
      rgba(255,255,255,0.008) 23px
    );
  pointer-events: none;
  z-index: 0;
}

.card-front-main {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.6rem;
  align-items: start;
  position: relative;
  z-index: 1;
}

.card-front-copy {
  display: grid;
  gap: 0.28rem;
}

.card-media {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 0;
  border: 1px solid var(--gold-dark);
  outline: 1px solid rgba(201,162,39,0.18);
  outline-offset: 2px;
  filter: sepia(0.25) contrast(1.05);
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.swipe-card h2 {
  margin: 0;
  line-height: 1.18;
  font-size: clamp(0.88rem, 2.4vw, 1.1rem);
  font-family: 'Cinzel', Georgia, serif;
  color: var(--gold-pale);
  letter-spacing: 0.02em;
}

.swipe-card .meta {
  margin: 0;
  color: rgba(240, 223, 160, 0.65);
  font-size: 0.7rem;
  font-style: italic;
  letter-spacing: 0.03em;
}

.swipe-card p {
  margin: 0;
  line-height: 1.45;
}

.lede-copy {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.82rem;
  line-height: 1.78;
  color: rgba(240, 223, 160, 0.88);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: normal;
  position: relative;
  z-index: 1;
}

/* ─── Read band (CTA footer) ─────────────────────────────── */

.read-band {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(201, 162, 39, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 34px;
  cursor: pointer;
  text-decoration: none;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-pale);
  transition: background 160ms ease;
}

.read-band::before {
  content: '⚜';
  font-size: 0.75em;
  opacity: 0.7;
}

.read-band::after {
  content: '⚜';
  font-size: 0.75em;
  opacity: 0.7;
}

/* ─── Sofia tone (Emerald House) ─────────────────────────── */

.swipe-card.tone-sofia .stack-count {
  color: #c8e8d0;
}

.swipe-card.tone-sofia {
  background: linear-gradient(170deg, #0e2218 0%, #071510 100%);
  border-color: #2a6040;
}

.swipe-card.tone-sofia::before {
  border-color: rgba(80, 180, 120, 0.3);
}

.swipe-card.tone-sofia::after {
  border-color: rgba(80, 180, 120, 0.12);
}

.swipe-card.tone-sofia h2,
.swipe-card.tone-sofia .front-copy,
.swipe-card.tone-sofia .card-content {
  color: #d8f0e0;
}

.swipe-card.tone-sofia .lede-copy,
.swipe-card.tone-sofia .meta {
  color: rgba(216, 240, 224, 0.88);
}

.swipe-card.tone-sofia .card-media {
  border-color: #2a6040;
  outline-color: rgba(80, 180, 120, 0.2);
}

.swipe-card.tone-sofia .read-band {
  background: rgba(10, 50, 28, 0.6);
  border-top-color: rgba(80, 180, 120, 0.3);
  color: #c8e8d0;
}

.swipe-card.tone-sofia .read-band:hover {
  background: rgba(20, 80, 45, 0.7);
}

/* ─── Quinn tone (Crimson House) ─────────────────────────── */

.swipe-card.tone-quinn .stack-count {
  color: #f0d0d5;
}

.swipe-card.tone-quinn {
  background: linear-gradient(170deg, #2a0a10 0%, #180508 100%);
  border-color: #7a1520;
}

.swipe-card.tone-quinn::before {
  border-color: rgba(200, 60, 80, 0.3);
}

.swipe-card.tone-quinn::after {
  border-color: rgba(200, 60, 80, 0.12);
}

.swipe-card.tone-quinn h2,
.swipe-card.tone-quinn .front-copy,
.swipe-card.tone-quinn .card-content {
  color: #f5e0e2;
}

.swipe-card.tone-quinn .lede-copy,
.swipe-card.tone-quinn .meta {
  color: rgba(245, 224, 226, 0.88);
}

.swipe-card.tone-quinn .card-media {
  border-color: #7a1520;
  outline-color: rgba(200, 60, 80, 0.2);
}

.swipe-card.tone-quinn .read-band {
  background: rgba(50, 8, 15, 0.6);
  border-top-color: rgba(200, 60, 80, 0.3);
  color: #f0d0d5;
}

.swipe-card.tone-quinn .read-band:hover {
  background: rgba(80, 12, 22, 0.7);
}

/* ─── Story viewer overlay ───────────────────────────────── */

.is-taking-over {
  overflow: hidden;
}

.is-story-open {
  overflow: hidden;
}

.story-templates {
  display: none;
}

.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(5, 3, 0, 0.82);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.story-viewer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.story-view-shell {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, 94vw);
  height: min(92vh, 760px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.4rem 1.6rem;
  border-radius: 0.3rem;
  border: 1px solid var(--gold-dark);
  background:
    linear-gradient(170deg, #2a1c0e, #1a1208);
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(201, 162, 39, 0.25),
    inset 0 0 60px rgba(201, 162, 39, 0.03);
  opacity: 0;
  transition:
    left 460ms cubic-bezier(0.2, 0.86, 0.28, 1),
    top 460ms cubic-bezier(0.2, 0.86, 0.28, 1),
    width 460ms cubic-bezier(0.2, 0.86, 0.28, 1),
    height 460ms cubic-bezier(0.2, 0.86, 0.28, 1),
    transform 460ms cubic-bezier(0.2, 0.86, 0.28, 1),
    border-radius 460ms cubic-bezier(0.2, 0.86, 0.28, 1),
    opacity 260ms ease;
  color: var(--parchment-dark);
}

/* Double border ornament on viewer */
.story-view-shell::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 162, 39, 0.2);
  pointer-events: none;
  z-index: 0;
}

.story-view-shell.tone-sofia {
  background: linear-gradient(170deg, #0e2218, #060f0c);
  border-color: #2a6040;
  color: #d8f0e0;
}

.story-view-shell.tone-sofia::before {
  border-color: rgba(80, 180, 120, 0.2);
}

.story-view-shell.tone-sofia .meta,
.story-view-shell.tone-sofia p,
.story-view-shell.tone-sofia li {
  color: rgba(216, 240, 224, 0.88);
}

.story-view-shell.tone-sofia .story-view-body {
  border-top-color: rgba(80, 180, 120, 0.2);
}

.story-view-shell.tone-sofia .story-close {
  background: rgba(20, 70, 40, 0.5);
  border-color: rgba(80, 180, 120, 0.4);
  color: #c8e8d0;
}

.story-view-shell.tone-quinn {
  background: linear-gradient(170deg, #2a0a10, #120406);
  border-color: #7a1520;
  color: #f5e0e2;
}

.story-view-shell.tone-quinn::before {
  border-color: rgba(200, 60, 80, 0.2);
}

.story-view-shell.tone-quinn .meta,
.story-view-shell.tone-quinn p,
.story-view-shell.tone-quinn li {
  color: rgba(245, 224, 226, 0.9);
}

.story-view-shell.tone-quinn .story-view-body {
  border-top-color: rgba(200, 60, 80, 0.2);
}

.story-view-shell.tone-quinn .story-close {
  background: rgba(60, 10, 18, 0.5);
  border-color: rgba(200, 60, 80, 0.4);
  color: #f0d0d5;
}

.story-view-shell.is-open {
  opacity: 1;
}

/* ─── Story close button ─────────────────────────────────── */

.story-close {
  border: 1px solid var(--gold-dark);
  background: rgba(201, 162, 39, 0.1);
  color: var(--gold-pale);
  border-radius: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
  transition: background 160ms ease;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 1;
}

.story-close::before {
  content: '✦ ';
  font-size: 0.6em;
  opacity: 0.7;
}

.story-close:hover {
  background: rgba(201, 162, 39, 0.22);
  border-color: var(--gold);
}

/* ─── Story body content ─────────────────────────────────── */

.story-view-body {
  margin-top: 0.9rem;
  border-top: 1px solid rgba(201, 162, 39, 0.22);
  padding-top: 0.9rem;
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-bottom: 2.2rem;
}

.story-view-body h1,
.story-view-body h2,
.story-view-body h3 {
  margin: 0.4rem 0 0.7rem;
  font-family: 'Cinzel', Georgia, serif;
  color: var(--gold-pale);
  letter-spacing: 0.03em;
}

.story-view-body p {
  margin: 0.55rem 0;
  line-height: 1.7;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.98rem;
}

.story-view-body img {
  width: min(280px, 100%);
  border-radius: 0;
  border: 1px solid var(--gold-dark);
  outline: 1px solid rgba(201, 162, 39, 0.2);
  outline-offset: 3px;
  filter: sepia(0.3) contrast(1.05);
}

/* ─── Story cards (standalone) ───────────────────────────── */

.story {
  border: 1px solid var(--gold-dark);
  background: linear-gradient(170deg, #2a1c0e, #1a1208);
  border-radius: 0;
  padding: 1rem;
}

.story img {
  width: 100%;
  max-width: 420px;
  border-radius: 0;
  display: block;
  margin: 0 auto 0.75rem;
  filter: sepia(0.25);
}

.meta {
  color: var(--gold-dark);
  font-size: 0.88rem;
  font-style: italic;
}

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 720px) {
  .wrap {
    width: min(100%, 95vw);
    padding: 0.8rem 0 1.5rem;
  }

  .deck {
    min-height: min(34vh, 260px);
  }

  .swipe-meta {
    font-size: 0.78rem;
  }

  .sim-controls {
    bottom: 0.7rem;
  }

  .story-view-shell {
    width: calc(100vw - 0.8rem);
    height: calc(100dvh - 0.8rem);
    padding: 0.85rem 0.85rem 1rem;
    border-radius: 0.22rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .story-close {
    top: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.64rem;
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(3px);
  }

  .story-view-body {
    margin-top: 0.65rem;
    padding-top: 0.7rem;
    padding-bottom: calc(1.8rem + env(safe-area-inset-bottom));
    font-size: 0.92rem;
  }

  .story-view-body h1 {
    font-size: clamp(1.55rem, 7vw, 2rem);
    line-height: 1.1;
  }

  .story-view-body h2 {
    font-size: clamp(1.2rem, 5.4vw, 1.55rem);
  }

  .story-view-body p {
    font-size: 1.02rem;
    line-height: 1.74;
  }

  .stack-grid {
    grid-template-columns: 1fr;
  }
}
