/* ─── Design Tokens ─── */
:root {
  --bg:           #050505;
  --surface:      #0d0d0d;
  --surface-2:    #111111;
  --ink:          #f0ede8;
  --ink-dim:      rgba(240, 237, 232, 0.52);
  --border:       rgba(255, 255, 255, 0.08);
  --border-mid:   rgba(255, 255, 255, 0.14);
  --red:          #e05a5a;
  --green:        #4ecb8c;
  --gold:         #c8a96e;
  --radius-card:  12px;
  --radius-btn:   6px;
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-1:     0 1px 3px rgba(0,0,0,0.4);
  --shadow-2:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-3:     0 24px 64px rgba(0,0,0,0.8);
  --nav-height:   75px;
  --rank-col-width: 56px;
  --index-col-width: 120px;
  --code-col-width: 118px;
  --ret-col-width: 112px;
  --pe-col-width: 90px;
  --div-col-width: 106px;
  --date-col-width: 128px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

/* ─── Nav ─── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  background: rgba(5, 5, 5, 0.48);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-brand-icon {
  width: 28px;
  height: 28px;
  background: var(--gold);
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.nav-brand-icon svg {
  width: 16px;
  height: 16px;
  fill: #050505;
}

.nav-brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.nav-link {
  color: var(--ink);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-btn);
  padding: 9px 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  transition: border-color 200ms var(--ease), color 200ms var(--ease), background 200ms var(--ease);
}

.nav-link:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(200, 169, 110, 0.08);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 200ms var(--ease), color 200ms var(--ease), transform 100ms var(--ease);
}

.refresh-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.refresh-btn:active { transform: scale(0.97); }

.refresh-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.refresh-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ─── Hero ─── */
.hero {
  position: relative;
  min-height: 88vh;
  overflow: hidden;
  isolation: isolate;
  background: #050505;
}

.hero-photo {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.hero-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  filter: contrast(1.06) brightness(0.88) saturate(0.98);
  transform: scale(1.01);
}

.hero[data-mentor="buffett-wall-street"] .hero-photo img {
  object-position: center center;
}

.hero[data-mentor="buffett-library"] .hero-photo img {
  object-position: center center;
}

.hero-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5,5,5,0.08) 0%, rgba(5,5,5,0.04) 30%, rgba(5,5,5,0.42) 55%, rgba(5,5,5,0.92) 100%),
    linear-gradient(180deg, rgba(5,5,5,0.18) 0%, rgba(5,5,5,0.03) 44%, rgba(5,5,5,0.8) 100%);
}

.hero::after {
  content: '';
  position: absolute;
  left: -6vw;
  right: -6vw;
  bottom: -2px;
  height: min(34vh, 280px);
  z-index: -1;
  pointer-events: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 30%, #000 100%);
  background:
    linear-gradient(to bottom, rgba(5,5,5,0) 0%, rgba(5,5,5,0.72) 46%, #050505 100%),
    radial-gradient(circle at 26% 92%, rgba(200,169,110,0.2), transparent 34%);
}

.hero-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 88vh;
  width: min(52vw, 720px);
  margin-left: auto;
  padding: 8vh 6vw 16vh 32px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}

.hero-tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

.hero-tag-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.hero-quote {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(30px, 3.6vw, 54px);
  font-weight: 700;
  line-height: 1.16;
  color: var(--ink);
  margin-bottom: 20px;
  text-wrap: balance;
}

.hero-quote em {
  font-style: italic;
  font-weight: 500;
  color: var(--gold);
}

.hero-translation {
  font-size: clamp(15px, 1.15vw, 18px);
  line-height: 1.75;
  color: rgba(240, 237, 232, 0.7);
  max-width: 560px;
  margin-bottom: 32px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.hero-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  padding: 5px 12px;
  background: rgba(200, 169, 110, 0.1);
  border: 1px solid rgba(200, 169, 110, 0.28);
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.hero-source {
  font-size: 11px;
  color: rgba(240, 237, 232, 0.46);
  letter-spacing: 0.02em;
}

/* ─── Telemetry Strip ─── */
.telemetry {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 8, 8, 0.66);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.telemetry-note {
  max-width: 1280px;
  margin: 8px auto 36px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  border-bottom: none;
}

.telemetry-note .telemetry-item {
  padding: 10px 14px;
}

.telemetry-note .telemetry-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(240, 237, 232, 0.44);
}

.telemetry-note .telemetry-value {
  font-size: 12px;
  font-weight: 500;
  color: rgba(240, 237, 232, 0.62);
}

.telemetry-note .telemetry-value.accent {
  color: rgba(200, 169, 110, 0.86);
}

.icp-note {
  max-width: 1280px;
  margin: 0 auto 26px;
  padding: 0 14px;
  text-align: center;
}

.icp-note a {
  color: rgba(240, 237, 232, 0.56);
  font-size: 12px;
  line-height: 1.6;
  text-decoration: none;
  border-bottom: 1px solid rgba(240, 237, 232, 0.22);
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}

.icp-note a:hover {
  color: rgba(240, 237, 232, 0.8);
  border-color: rgba(240, 237, 232, 0.42);
}

.telemetry-item {
  padding: 20px 24px;
  border-right: 1px solid var(--border);
}

.telemetry-item:last-child { border-right: none; }

.telemetry-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.telemetry-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.telemetry-value.accent { color: var(--gold); }

/* ─── Data Section ─── */
.data-section {
  position: relative;
  z-index: 1;
  padding: 82px 40px 80px;
  max-width: 1280px;
  margin: 0 auto;
}

.data-section::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: -130px;
  left: 50%;
  width: 120vw;
  height: 220px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, rgba(5,5,5,0.28), #050505 72%);
  pointer-events: none;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 24px;
}

.section-title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.section-title {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  background: rgba(78, 203, 140, 0.1);
  border: 1px solid rgba(78, 203, 140, 0.25);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.status-chip.warn {
  background: rgba(224, 90, 90, 0.1);
  border-color: rgba(224, 90, 90, 0.25);
  color: var(--red);
}

.status-chip.warn::before {
  background: var(--red);
  animation: none;
}

/* ─── Table ─── */
.table-wrap {
  position: relative;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: auto;
  max-height: min(72vh, 720px);
  -webkit-overflow-scrolling: touch;
  scrollbar-color: rgba(200, 169, 110, 0.55) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
}

.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(200, 169, 110, 0.55);
  border-radius: 999px;
}

.data-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.col-rank { width: var(--rank-col-width); }
.col-index { width: var(--index-col-width); }
.col-code { width: var(--code-col-width); }
.col-ret { width: var(--ret-col-width); }
.col-pe { width: var(--pe-col-width); }
.col-div { width: var(--div-col-width); }
.col-date { width: var(--date-col-width); }

.data-table thead { background: var(--surface-2); }

th {
  padding: 14px 18px;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  background-clip: padding-box;
}

th:first-child,
th:nth-child(2),
th:nth-child(3) {
  text-align: left;
}

thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 7;
  width: var(--rank-col-width);
  min-width: var(--rank-col-width);
  max-width: var(--rank-col-width);
  background: var(--surface-2);
}

thead th:nth-child(2) {
  position: sticky;
  left: var(--rank-col-width);
  z-index: 6;
  width: var(--index-col-width);
  min-width: var(--index-col-width);
  background: var(--surface-2);
}

td {
  padding: 15px 18px;
  text-align: right;
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: background 160ms var(--ease);
  background-clip: padding-box;
}

td:first-child,
td:nth-child(2),
td:nth-child(3) {
  text-align: left;
}

tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  width: var(--rank-col-width);
  min-width: var(--rank-col-width);
  max-width: var(--rank-col-width);
  background: #0a0a0a;
}

tbody td:nth-child(2) {
  position: sticky;
  left: var(--rank-col-width);
  z-index: 4;
  width: var(--index-col-width);
  min-width: var(--index-col-width);
  background: #0c0c0c;
  box-shadow:
    1px 0 0 rgba(255, 255, 255, 0.08),
    10px 0 18px -14px rgba(200, 169, 110, 0.28);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background 160ms var(--ease);
}

tbody tr:hover td { background: rgba(200, 169, 110, 0.04); }

tbody tr:hover td:first-child {
  border-left: 2px solid var(--gold);
  padding-left: 16px;
}

/* Rank */
.rank-num {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}

/* Index name */
.name-cell {
  font-weight: 700;
  font-size: 15px;
}

/* Market chip */
.market-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.market-chip.ashare {
  background: rgba(224, 90, 90, 0.15);
  color: var(--red);
  border: 1px solid rgba(224, 90, 90, 0.3);
}

.market-chip.us {
  background: rgba(78, 203, 140, 0.12);
  color: var(--green);
  border: 1px solid rgba(78, 203, 140, 0.25);
}

/* Code */
.code-cell {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--ink-dim);
}

/* Return cells */
.ret-cell { font-weight: 700; }

.ret-cell .rank-hint {
  display: inline-block;
  margin-left: 5px;
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-dim);
}

/* Up / Down / Flat */
.up   { color: var(--red); }
.down { color: var(--green); }
.flat { color: var(--ink); }

/* PE */
.pe-cell {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
}

/* Dividend yield */
.div-cell {
  font-size: 13px;
  color: var(--ink-dim);
}

/* Date */
.date-cell {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--ink-dim);
}

/* ─── Responsive — Tablet ─── */
@media (max-width: 900px) {
  .top-nav {
    padding: 14px 20px;
  }
  :root { --nav-height: 66px; }

  .nav-label { display: none; }
  .nav-right { gap: 10px; }
  .nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
  }

  .hero {
    min-height: 82vh;
  }

  .hero-photo {
    position: absolute;
    height: auto;
    min-height: 0;
  }

  .hero[data-mentor="buffett-wall-street"] .hero-photo img {
    object-position: 31% center;
  }

  .hero[data-mentor="buffett-library"] .hero-photo img {
    object-position: 28% center;
  }

  .hero-photo::after {
    background:
      linear-gradient(180deg, rgba(5,5,5,0.08) 0%, rgba(5,5,5,0.12) 35%, rgba(5,5,5,0.88) 78%, #050505 100%),
      linear-gradient(90deg, rgba(5,5,5,0.02) 0%, rgba(5,5,5,0.32) 62%, rgba(5,5,5,0.82) 100%);
  }

  .hero-content {
    min-height: 82vh;
    width: 100%;
    margin-left: 0;
    padding: clamp(260px, 45vh, 440px) 24px 112px;
    z-index: 2;
  }

  .hero-tag { margin-bottom: 18px; }

  .hero-quote {
    max-width: 720px;
    font-size: clamp(30px, 6vw, 46px);
    line-height: 1.18;
  }

  .hero-translation {
    max-width: 620px;
    margin-bottom: 24px;
    color: rgba(240, 237, 232, 0.66);
  }

  .telemetry {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 0;
  }

  .telemetry-item { padding: 14px 12px; }
  .telemetry-value { font-size: 13px; }

  .data-section { padding: 58px 20px 60px; }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-wrap {
    margin-inline: -20px;
    padding-inline: 20px;
  }

  .data-table { min-width: 900px; }
}

/* ─── Responsive — Mobile ─── */
@media (max-width: 540px) {
  :root {
    --nav-height: 58px;
    --rank-col-width: 52px;
    --index-col-width: 108px;
    --code-col-width: 92px;
    --ret-col-width: 96px;
    --pe-col-width: 72px;
    --div-col-width: 86px;
    --date-col-width: 98px;
  }

  .top-nav {
    padding: 12px 14px;
  }

  .nav-brand-name {
    max-width: 116px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-right { gap: 8px; }

  .nav-link {
    min-height: 34px;
    padding: 0 10px;
    font-size: 10px;
    letter-spacing: 0.05em;
    white-space: nowrap;
  }

  .refresh-btn {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    font-size: 0;
    letter-spacing: 0;
  }

  .refresh-btn svg {
    width: 14px;
    height: 14px;
  }

  .hero-photo {
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .hero-photo img {
    inset: 0 auto auto 0;
    width: 100%;
    height: auto;
    min-height: 0;
    object-fit: contain;
    object-position: top center;
    transform: none;
  }

  .hero-photo::after {
    background:
      linear-gradient(180deg, rgba(5,5,5,0.02) 0%, rgba(5,5,5,0.2) 34%, rgba(5,5,5,0.82) 62%, #050505 100%),
      linear-gradient(90deg, rgba(5,5,5,0.02) 0%, rgba(5,5,5,0.28) 68%, rgba(5,5,5,0.78) 100%);
  }

  .hero-content {
    min-height: auto;
    padding: clamp(230px, 58vw, 330px) 18px 88px;
  }

  .hero-tag-text {
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .hero-quote {
    font-size: clamp(24px, 8vw, 31px);
    line-height: 1.18;
    margin-bottom: 14px;
  }

  .hero-translation {
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 22px;
  }

  .hero-source {
    max-width: 100%;
  }

  .telemetry {
    grid-template-columns: 1fr;
    margin-top: 0;
  }

  .telemetry-item {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .telemetry-item:last-child { border-bottom: none; }

  .icp-note {
    margin-bottom: 20px;
    padding-inline: 16px;
    text-align: left;
  }

  .data-section {
    padding: 34px 16px 56px;
  }

  .section-title {
    font-size: 30px;
    line-height: 1.08;
  }

  .table-wrap {
    margin-inline: -16px;
    padding-inline: 0;
    max-height: 68vh;
  }

  .data-table {
    table-layout: fixed;
    min-width: 724px;
    font-size: 13px;
    --index-col-width: 92px;
    --code-col-width: 86px;
    --ret-col-width: 88px;
    --pe-col-width: 68px;
    --div-col-width: 86px;
    --date-col-width: 96px;
  }

  .col-rank {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    visibility: collapse;
  }

  .col-index { width: var(--index-col-width); }
  .col-code { width: var(--code-col-width); }
  .col-ret { width: var(--ret-col-width); }
  .col-pe { width: var(--pe-col-width); }
  .col-div { width: var(--div-col-width); }
  .col-date { width: var(--date-col-width); }

  thead th:first-child,
  tbody td:first-child {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  thead th:nth-child(2),
  tbody td:nth-child(2) {
    left: 0 !important;
  }

  th,
  td {
    padding: 13px 14px;
  }

  thead th:first-child { z-index: 8; }
  thead th:nth-child(2) { z-index: 7; }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .status-chip::before { animation: none; }
}
