/* ============================================================
   Enimates — Character Portal (proto-b)
   Model: gacha-official-site structure, kid-warm SEL execution
   ============================================================ */

:root {
  /* Family colors (mirrored from characters.json for CSS use) */
  --c-joy: #F2B705;         --c-joy-dark: #B37D00;
  --c-trust: #1F9E8E;       --c-trust-dark: #0E5C51;
  --c-fear: #8B6BC7;        --c-fear-dark: #5A3E8C;
  --c-surprise: #F0559B;    --c-surprise-dark: #B32671;
  --c-sadness: #3A6FD8;     --c-sadness-dark: #1E3E8C;
  --c-anger: #D8402E;       --c-anger-dark: #8C1E12;
  --c-disgust: #6FBF3E;     --c-disgust-dark: #3D7A1C;
  --c-anticipation: #E8791A; --c-anticipation-dark: #A6520A;

  /* Base palette — warm cream storybook, not white */
  --bg: #FBF3E4;
  --bg-deep: #F4E7CF;
  --ink: #2B2320;
  --ink-soft: #6B5D51;
  --paper: #FFFCF6;
  --line: #E4D4B8;
  --accent: var(--c-anticipation);
  --accent-dark: var(--c-anticipation-dark);

  --rail-w: 224px;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-soft: 0 12px 32px -14px rgba(43, 35, 32, 0.28);
  --shadow-pop: 0 18px 40px -12px rgba(43, 35, 32, 0.35);

  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

/* subtle grain for warmth, avoids flat-vector-slop */
.grain-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.05; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin: 0 0 0.6em;
}

.section-head { max-width: 620px; margin: 0 auto 3rem; text-align: center; }
.section-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  margin: 0 0 0.6rem;
  line-height: 1.15;
}
.section-sub { color: var(--ink-soft); font-size: 1.02rem; margin: 0; }

/* ============================================================
   RAIL NAV — signature element: numbered vertical rail
   ============================================================ */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--rail-w);
  background: var(--paper);
  border-right: 2px solid var(--line);
  z-index: 100;
  display: flex; flex-direction: column;
  padding: 1.6rem 1.2rem;
}

.rail-mark { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 2.6rem; }
.rail-mark-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: conic-gradient(var(--c-joy), var(--c-trust), var(--c-fear), var(--c-surprise), var(--c-sadness), var(--c-anger), var(--c-disgust), var(--c-anticipation), var(--c-joy));
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--line);
}
.rail-mark-text { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }

.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.rail-link {
  display: flex; align-items: baseline; gap: 0.7rem;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 0.95rem; color: var(--ink-soft);
  position: relative;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.rail-link .num { font-size: 0.72rem; font-weight: 800; color: var(--line); font-variant-numeric: tabular-nums; transition: color 0.2s ease; }
.rail-link:hover { background: var(--bg-deep); color: var(--ink); transform: translateX(2px); }
.rail-link.is-active { color: var(--ink); background: var(--bg-deep); }
.rail-link.is-active .num { color: var(--accent-dark); }
.rail-link.is-active::before {
  content: ''; position: absolute; left: -1.2rem; top: 50%; transform: translateY(-50%);
  width: 4px; height: 60%; border-radius: 4px; background: var(--accent);
}

.rail-toggle { display: none; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  margin-left: var(--rail-w);
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6rem 2rem 4rem;
  overflow: hidden;
  background:
    radial-gradient(ellipse 900px 500px at 18% 8%, rgba(242,183,5,0.16), transparent 60%),
    radial-gradient(ellipse 800px 600px at 85% 85%, rgba(240,85,155,0.14), transparent 60%),
    var(--bg);
}

.hero-blobs { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(0.5px);
  opacity: 0.9;
  animation: float 9s ease-in-out infinite;
}
.b1 { width: 46px; height: 46px; left: 8%; top: 20%; background: var(--c-joy); animation-delay: 0s; }
.b2 { width: 28px; height: 28px; left: 15%; top: 62%; background: var(--c-trust); animation-delay: 1.2s; }
.b3 { width: 34px; height: 34px; left: 27%; top: 12%; background: var(--c-fear); animation-delay: 2.1s; }
.b4 { width: 22px; height: 22px; right: 32%; top: 78%; background: var(--c-surprise); animation-delay: 0.6s; }
.b5 { width: 38px; height: 38px; right: 18%; top: 22%; background: var(--c-sadness); animation-delay: 1.8s; }
.b6 { width: 30px; height: 30px; right: 9%; top: 58%; background: var(--c-anger); animation-delay: 2.6s; }
.b7 { width: 24px; height: 24px; right: 24%; top: 10%; background: var(--c-disgust); animation-delay: 0.9s; }
.b8 { width: 42px; height: 42px; left: 40%; top: 84%; background: var(--c-anticipation); animation-delay: 1.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }

.hero-inner { position: relative; z-index: 1; max-width: 780px; text-align: center; }
.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
}
.hero-title-accent {
  color: var(--accent-dark);
  position: relative;
  white-space: nowrap;
}
.hero-title-accent::after {
  content: '';
  position: absolute; left: -2%; right: -2%; bottom: 0.06em; height: 0.32em;
  background: var(--c-joy);
  opacity: 0.45;
  z-index: -1;
  border-radius: 6px;
  transform: rotate(-1deg);
}

.hero-sub { font-size: clamp(1.02rem, 1.4vw, 1.18rem); color: var(--ink-soft); max-width: 560px; margin: 0 auto 2.2rem; }

.hero-actions { display: flex; gap: 0.9rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-display); font-weight: 800; font-size: 1rem;
  padding: 0.85rem 1.7rem; border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.btn-ghost {
  background: transparent; color: var(--ink); border-color: var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

.scroll-cue {
  position: absolute; bottom: 2.2rem; left: 50%; transform: translateX(-50%);
  width: 26px; height: 42px; border: 2px solid var(--ink-soft); border-radius: 14px;
  display: flex; justify-content: center; padding-top: 7px;
}
.scroll-cue-line { width: 3px; height: 8px; border-radius: 2px; background: var(--ink-soft); animation: scrollcue 1.6s ease-in-out infinite; }
@keyframes scrollcue { 0% { opacity: 1; transform: translateY(0); } 70% { opacity: 0; transform: translateY(10px); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .scroll-cue-line { animation: none; } }

/* ============================================================
   ROSTER — the centerpiece
   ============================================================ */
.roster { margin-left: var(--rail-w); padding: 5.5rem 2.5rem 6rem; max-width: 1400px; }

.family-tabs {
  display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center;
  margin-bottom: 2.4rem;
}
.family-tab {
  font-family: var(--font-display); font-weight: 800; font-size: 0.85rem;
  padding: 0.55rem 1.1rem; border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; align-items: center; gap: 0.5rem;
  transition: all 0.18s ease;
}
.family-tab .dot { width: 10px; height: 10px; border-radius: 50%; }
.family-tab:hover { border-color: var(--fam-color, var(--ink)); transform: translateY(-1px); }
.family-tab.is-active {
  background: var(--fam-color, var(--ink));
  border-color: var(--fam-color, var(--ink));
  color: #fff;
}

.roster-layout {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 2.4rem;
  align-items: start;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.roster-card {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.6rem 0.8rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.roster-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-soft); border-color: var(--fam-color); }
.roster-card.is-selected {
  border-color: var(--fam-color);
  background: color-mix(in srgb, var(--fam-color) 10%, var(--paper));
  box-shadow: var(--shadow-soft);
}
.roster-card .thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-deep);
  margin-bottom: 0.5rem;
}
.roster-card img { width: 100%; height: 100%; object-fit: cover; }
.roster-card .badge {
  position: absolute; top: 5px; right: 5px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--fam-color);
  border: 2px solid var(--paper);
}
.roster-card .name { font-weight: 800; font-size: 0.78rem; line-height: 1.25; display: block; }
.roster-card .intensity-tier { font-size: 0.66rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

/* intensity ladder — scale reflects low/core/high */
.roster-card[data-intensity="low"] .thumb-wrap { transform: scale(0.86); transform-origin: center; }
.roster-card[data-intensity="core"] .thumb-wrap { transform: scale(0.96); transform-origin: center; }
.roster-card[data-intensity="high"] .thumb-wrap { transform: scale(1.04); transform-origin: center; }

/* ---- detail panel ---- */
.detail-panel { position: sticky; top: 2rem; }
.detail-card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: var(--shadow-pop);
  position: relative;
  overflow: hidden;
}
.detail-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: var(--fam-color, var(--accent));
}
.detail-top { display: flex; gap: 1.4rem; align-items: flex-start; margin-bottom: 1.2rem; }
.detail-portrait-wrap {
  width: 156px; height: 156px; border-radius: var(--radius-md);
  overflow: hidden; flex-shrink: 0;
  background: var(--bg-deep);
  border: 3px solid var(--fam-color, var(--line));
}
.detail-portrait-wrap img { width: 100%; height: 100%; object-fit: cover; }
.detail-heading { flex: 1; }
.detail-family-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fam-color-dark, var(--accent-dark));
  background: color-mix(in srgb, var(--fam-color) 16%, var(--paper));
  padding: 0.28rem 0.65rem; border-radius: 999px;
  margin-bottom: 0.55rem;
}
.detail-family-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fam-color); }
.detail-name { font-family: var(--font-display); font-weight: 800; font-size: 1.55rem; margin: 0 0 0.15rem; line-height: 1.1; }
.detail-animal { color: var(--ink-soft); font-weight: 700; font-size: 0.95rem; margin: 0; }

.detail-trait {
  font-size: 1.02rem; line-height: 1.55;
  padding: 0.9rem 1.05rem;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  margin: 0 0 1.2rem;
  border-left: 4px solid var(--fam-color, var(--accent));
}

.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.detail-meta-item {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
}
.detail-meta-label { font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); display: block; margin-bottom: 0.2rem; }
.detail-meta-value { font-weight: 800; font-size: 0.95rem; }

.detail-ladder { display: flex; align-items: flex-end; gap: 0.4rem; margin-top: 1.3rem; }
.detail-ladder-step {
  flex: 1; text-align: center; padding: 0.5rem 0.3rem 0.4rem;
  border-radius: 10px 10px 4px 4px;
  border: 1.5px solid var(--line);
  font-size: 0.68rem; font-weight: 800; color: var(--ink-soft);
  background: var(--bg-deep);
}
.detail-ladder-step.is-current {
  background: var(--fam-color); color: #fff; border-color: var(--fam-color);
}
.detail-ladder-step[data-tier="low"] { height: 44px; }
.detail-ladder-step[data-tier="core"] { height: 58px; }
.detail-ladder-step[data-tier="high"] { height: 72px; }

/* ============================================================
   WORLD
   ============================================================ */
.world { margin-left: var(--rail-w); padding: 5rem 2.5rem 6rem; background: var(--bg-deep); }
.world-grid {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem;
}
.world-card {
  border-radius: var(--radius-md);
  padding: 1.6rem 1.3rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  min-height: 148px;
  display: flex; flex-direction: column; justify-content: flex-end;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease;
}
.world-card:hover { transform: translateY(-4px) rotate(-0.4deg); }
.world-card::after {
  content: '';
  position: absolute; top: -30%; right: -20%; width: 60%; height: 90%;
  background: rgba(255,255,255,0.14); border-radius: 50%;
}
.world-card-eyebrow { font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; margin-bottom: 0.3rem; }
.world-card-name { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; margin: 0; }

/* ============================================================
   NEWS
   ============================================================ */
.news { margin-left: var(--rail-w); padding: 5.5rem 2.5rem 6rem; }
.news-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.news-card {
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius-md);
  padding: 1.5rem; display: flex; flex-direction: column; gap: 0.55rem;
}
.news-tag {
  align-self: flex-start;
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--bg-deep); color: var(--accent-dark); padding: 0.28rem 0.6rem; border-radius: 999px;
}
.news-card h3 { font-family: var(--font-display); font-size: 1.1rem; margin: 0.2rem 0 0; }
.news-card p { color: var(--ink-soft); font-size: 0.92rem; margin: 0; flex: 1; }
.news-date { font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); }

/* ============================================================
   FOR GROWN-UPS
   ============================================================ */
.grownups { margin-left: var(--rail-w); padding: 5.5rem 2.5rem 6.5rem; background: var(--ink); color: var(--paper); }
.grownups-inner { max-width: 900px; margin: 0 auto; text-align: center; }
.grownups .eyebrow { color: var(--c-joy); }
.grownups .section-title { color: var(--paper); }
.grownups-copy { color: #D8CFC3; font-size: 1.02rem; line-height: 1.7; max-width: 680px; margin: 0 auto 2.6rem; }
.grownups-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; text-align: left; }
.grownups-point {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.3rem;
}
.grownups-point-num { font-family: var(--font-display); font-weight: 800; color: var(--c-joy); font-size: 0.85rem; }
.grownups-point h3 { font-family: var(--font-display); margin: 0.4rem 0 0.4rem; font-size: 1.05rem; }
.grownups-point p { color: #B8AFA3; font-size: 0.9rem; margin: 0; line-height: 1.55; }

.site-footer {
  margin-left: var(--rail-w);
  padding: 1.6rem 2.5rem;
  background: var(--ink);
  color: #8a8075;
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1080px) {
  .roster-layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .world-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  :root { --rail-w: 0px; }
  .rail {
    width: 100%; height: auto; flex-direction: row; align-items: center;
    border-right: none; border-bottom: 2px solid var(--line);
    padding: 0.8rem 1.2rem;
  }
  .rail-mark { margin-bottom: 0; }
  .rail-list {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--paper); border-bottom: 2px solid var(--line);
    padding: 0.6rem; flex-direction: column;
  }
  .rail-list.is-open { display: flex; }
  .rail-toggle {
    display: flex; flex-direction: column; gap: 4px; margin-left: auto;
    background: none; border: none; cursor: pointer; padding: 0.5rem;
  }
  .rail-toggle span { width: 22px; height: 2.5px; background: var(--ink); border-radius: 2px; }
  .hero, .roster, .world, .news, .grownups, .site-footer { margin-left: 0; }
  .roster-grid { grid-template-columns: repeat(3, 1fr); }
  .news-grid { grid-template-columns: 1fr; }
  .grownups-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .roster-grid { grid-template-columns: repeat(2, 1fr); }
  .world-grid { grid-template-columns: 1fr; }
  .detail-top { flex-direction: column; align-items: center; text-align: center; }
  .detail-meta { grid-template-columns: 1fr; }
}
