/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: #F7F3EF;
  color: #1a1a1a;
  font-family: 'Outfit', 'Noto Sans TC', sans-serif;
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --cream:      #F7F3EF;
  --cream-dark: #EDE8E2;
  --ink:        #1a1a1a;
  --ink-mid:    #444;
  --muted:      #888;
  --muted-lt:   #bbb;
  --gold:       #C4956A;
  --gold-bg:    rgba(196, 149, 106, 0.1);
  --dark-bg:    #111;
  --dark-text:  #f0ece6;
  --border:     rgba(0,0,0,0.08);
  --green:      #2e7d32;
  --green-bg:   rgba(76, 175, 80, 0.1);
  --red:        #c62828;
  --red-bg:     rgba(244, 67, 54, 0.08);
}

/* ============================================================
   GRAIN OVERLAY
   ============================================================ */
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 20px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
  background: rgba(247,243,239,0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-back {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 0.2s;
}
.nav-back:hover { color: var(--ink); }
.nav-title {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ============================================================
   EYEBROW
   ============================================================ */
.eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
}
.eyebrow.light { color: rgba(255,255,255,0.35); }

/* ============================================================
   OPENING
   ============================================================ */
.opening {
  padding: 180px 48px 100px;
  max-width: 1100px;
  margin: 0 auto;
}
.project-meta {
  display: flex;
  gap: 32px;
  align-items: baseline;
  margin-bottom: 52px;
  flex-wrap: wrap;
}
/* override global eyebrow margin when used inline */
.project-meta .eyebrow { margin-bottom: 0; }
.year {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.15em;
}
.main-statement {
  font-family: 'Outfit', sans-serif;
  font-weight: 200;
  font-size: clamp(3rem, 5.5vw, 5.5rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin-bottom: 52px;
  color: var(--ink);
}
.gold { color: var(--gold); }
.opening-context {
  font-size: 0.78rem;
  color: var(--ink-mid);
  opacity: 0.6;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
  max-width: 520px;
  font-family: 'Noto Sans TC', sans-serif;
}
.opening-desc {
  font-size: 0.92rem;
  color: var(--ink-mid);
  line-height: 2;
  max-width: 520px;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 300;
}

/* ============================================================
   STATS ROW
   ============================================================ */
.stats-row {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 52px 48px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 1100px;
  margin: 0 auto;
  gap: 16px;
}
.stat { text-align: center; padding: 8px; }
.stat-number {
  font-size: clamp(2.8rem, 4.5vw, 4.5rem);
  font-weight: 200;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 10px;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================================
   ARCHITECTURE
   ============================================================ */
.architecture {
  background: var(--dark-bg);
  padding: 100px 48px;
}
.arch-content { max-width: 1100px; margin: 0 auto; }
.architecture h2 {
  font-family: 'Outfit', sans-serif;
  font-weight: 200;
  font-size: clamp(2rem, 3.5vw, 3rem);
  color: var(--dark-text);
  margin-bottom: 64px;
  letter-spacing: -0.02em;
}
.flow-diagram {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.flow-node { flex: 1; min-width: 200px; }
.flow-label {
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}
.flow-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flow-items span {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.55);
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  transition: border-color 0.2s, color 0.2s;
}
.flow-items span:hover {
  border-color: rgba(196,149,106,0.4);
  color: rgba(255,255,255,0.85);
}
.flow-arrow {
  font-size: 1.4rem;
  color: var(--gold);
  opacity: 0.5;
  padding-top: 28px;
  align-self: flex-start;
  flex-shrink: 0;
}

/* ============================================================
   SECTION SHELL
   ============================================================ */
.tools, .ai-stories, .demo {
  padding: 100px 48px;
  max-width: 1100px;
  margin: 0 auto;
}
.section-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 200;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.015em;
  margin-bottom: 12px;
}
.section-desc {
  font-size: 0.88rem;
  color: var(--ink-mid);
  margin-bottom: 48px;
  line-height: 1.9;
  font-family: 'Noto Sans TC', sans-serif;
}

/* ============================================================
   TOOL CARDS
   ============================================================ */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  border: 1px solid var(--border);
  gap: 1px;
  background: var(--border);
  margin-top: 40px;
}
.tool-card {
  background: var(--cream);
  padding: 32px;
  transition: background 0.2s;
  cursor: default;
}
.tool-card:hover { background: #fff; }
.tool-num {
  font-size: 0.62rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  margin-bottom: 14px;
  font-weight: 400;
}
.tool-name {
  font-size: 0.98rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink);
}
.tool-name-zh {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'Noto Sans TC', sans-serif;
  margin-bottom: 14px;
}
.tool-desc {
  font-size: 0.8rem;
  color: var(--ink-mid);
  line-height: 1.75;
  font-family: 'Noto Sans TC', sans-serif;
}

/* ============================================================
   AI STORIES
   ============================================================ */
.ai-stories {
  border-top: 1px solid var(--border);
  padding-top: 100px;
}
.stories-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.story-item {
  padding: 48px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 32px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.story-item.visible { opacity: 1; transform: translateY(0); }
.story-num {
  font-size: 0.62rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  padding-top: 4px;
  font-weight: 400;
}
.story-title {
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 14px;
  color: var(--ink);
  font-style: italic;
}
.story-text {
  font-size: 0.84rem;
  color: var(--ink-mid);
  line-height: 1.85;
  font-family: 'Noto Sans TC', sans-serif;
  max-width: 680px;
}
.story-tag {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.68rem;
  color: var(--gold);
  border: 1px solid rgba(196,149,106,0.3);
  background: var(--gold-bg);
  padding: 4px 12px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  font-family: 'Outfit', sans-serif;
}

/* ============================================================
   DEMO SECTION
   ============================================================ */
.demo {
  border-top: 1px solid var(--border);
  padding-top: 100px;
}

/* League tabs */
.league-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none;
  border: none;
  padding: 16px 36px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
  color: var(--muted);
  font-family: 'Outfit', sans-serif;
}
.tab-btn > span:first-child {
  font-size: 0.92rem;
  font-weight: 500;
  color: inherit;
}
.tab-btn.active { border-bottom-color: var(--gold); color: var(--ink); }
.tab-btn:hover { color: var(--ink-mid); }
.tab-sub {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Demo description box */
.demo-desc {
  background: var(--cream-dark);
  padding: 14px 20px;
  border-radius: 3px;
  margin-bottom: 20px;
  font-size: 0.8rem;
  color: var(--ink-mid);
  line-height: 1.75;
  font-family: 'Noto Sans TC', sans-serif;
}
.demo-desc strong { color: var(--ink); font-weight: 500; }
.val-pos { color: var(--green); }
.val-neg { color: var(--red); }

/* Sub-tabs (打者/SP/RP) */
.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.sub-tab {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 18px;
  font-size: 0.78rem;
  cursor: pointer;
  border-radius: 2px;
  color: var(--muted);
  font-family: 'Noto Sans TC', sans-serif;
  transition: all 0.2s;
}
.sub-tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.sub-tab:hover:not(.active) { border-color: var(--ink-mid); color: var(--ink-mid); }

/* Position filter pills */
.pos-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.pos-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 13px;
  font-size: 0.72rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-radius: 2px;
  font-family: 'Outfit', sans-serif;
  transition: all 0.15s;
}
.pos-btn:hover { border-color: var(--ink-mid); color: var(--ink-mid); }
.pos-btn.active {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

/* Table wrapper */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 8px;
}
.hidden { display: none !important; }
.demo-panel { display: none; }
.demo-panel.active { display: block; }

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--cream-dark);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--ink); }
.data-table thead th.active-sort { color: var(--ink); }
.sort-icon { opacity: 0.5; font-size: 0.7rem; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gold-bg); }
.data-table td { padding: 10px 16px; vertical-align: middle; }

/* Player name cell */
.player-name { font-weight: 500; font-size: 0.86rem; color: var(--ink); white-space: nowrap; }
.player-team { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

/* Position badge */
.pos-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 8px;
  background: var(--cream-dark);
  border-radius: 2px;
  letter-spacing: 0.05em;
  color: var(--ink-mid);
  font-family: 'Outfit', sans-serif;
  white-space: nowrap;
}

/* FP value */
.fp-val {
  font-weight: 500;
  font-size: 0.9rem;
}
.fp-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fp-bar-track {
  width: 60px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  flex-shrink: 0;
}
.fp-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
  opacity: 0.6;
}

/* Delta badge */
.delta-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 2px;
  font-family: 'Outfit', sans-serif;
}
.delta-pos { background: var(--green-bg); color: var(--green); }
.delta-neg { background: var(--red-bg); color: var(--red); }
.delta-zero { color: var(--muted); font-size: 0.8rem; }

/* Z-Score cell */
.z-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 90px;
}
.z-val {
  min-width: 38px;
  font-weight: 500;
  font-size: 0.82rem;
  font-family: 'Outfit', sans-serif;
}
.z-bar-track {
  width: 56px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  flex-shrink: 0;
  overflow: hidden;
}
.z-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
}
.z-bar-fill.neg { background: #ccc; }
.z-total-val {
  font-weight: 600;
  font-size: 0.92rem;
  font-family: 'Outfit', sans-serif;
}

/* ============================================================
   CLOSING
   ============================================================ */
.closing {
  text-align: center;
  padding: 120px 48px;
  border-top: 1px solid var(--border);
}
.closing-statement {
  font-family: 'Outfit', sans-serif;
  font-weight: 200;
  font-size: clamp(2.2rem, 4.5vw, 4rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin-bottom: 20px;
}
.closing-zh {
  font-size: 0.88rem;
  color: var(--muted);
  font-family: 'Noto Sans TC', sans-serif;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  padding: 24px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
.footer-link {
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.footer-link:hover { color: var(--ink); }

/* ============================================================
   SCROLL REVEAL
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.75s ease, transform 0.75s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .nav { padding: 16px 24px; }
  .opening { padding: 140px 24px 60px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); padding: 36px 24px; }
  .architecture { padding: 60px 24px; }
  .flow-diagram { flex-direction: column; gap: 12px; }
  .flow-arrow { transform: rotate(90deg); align-self: center; padding-top: 0; }
  .tools, .ai-stories, .demo { padding: 60px 24px; }
  .tools-grid { grid-template-columns: 1fr; }
  .story-item { grid-template-columns: 40px 1fr; gap: 16px; }
  .closing { padding: 80px 24px; }
  .footer { padding: 20px 24px; }
  .tab-btn { padding: 12px 20px 10px; }
}
