﻿/* ════════════════════════════════════
   INDEXWATCH — GLOBAL MARKET COMPARISON
   Design tokens
════════════════════════════════════ */

:root {
  /* Color */
  --navy:        #0F1B2E;
  --navy-soft:   #1B2D47;
  --cream:       #F7F5F0;
  --paper:       #FFFFFF;
  --border:      #E4DFD3;
  --ink:         #232323;
  --muted:       #6B6459;

  /* Index colors */
  --c-nifty:     #2E86AB;
  --c-sp500:     #C1432A;
  --c-nasdaq:    #3D5A80;
  --c-shanghai:  #B8860B;
  --c-dax:       #5C7A5C;

  /* Signal */
  --gain:        #1A7A4C;
  --loss:        #B8312F;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
   overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--c-nifty);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Header ── */
.site-header {
  background: var(--navy);
  padding: 0 24px;
  position: relative;
}

@media (max-width: 640px) {
  .site-header {
    position: relative;
  }
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--paper);
}

.logo-mark {
  color: var(--c-sp500);
  font-size: 1.3rem;
}

.logo-text em {
  font-style: italic;
  font-weight: 400;
  color: rgba(255,255,255,0.65);
}

.header-nav {
  display: flex;
  gap: 28px;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s var(--ease);
}

.nav-link:hover { color: rgba(255,255,255,0.85); }

.nav-link.active {
  color: var(--paper);
  border-bottom-color: var(--c-sp500);
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.hamburger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--paper);
  border-radius: 2px;
}

@media (max-width: 640px) {
  .header-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--navy);
    border-top: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 20px rgba(15,27,46,0.25);
    z-index: 20;
  }

  .header-nav.open {
    display: flex;
  }

  .header-nav .nav-link {
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .header-nav .nav-link.active {
    border-left: 3px solid var(--c-sp500);
    padding-left: 21px;
  }

  .hamburger-btn {
    display: flex;
  }
}

/* ── Page intro ── */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.page-intro {
  padding: 48px 0 28px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--c-sp500);
  margin: 0 0 12px;
}

.eyebrow::before {
  content: '';
  width: 18px;
  height: 2px;
  background: var(--c-sp500);
}

.page-title {
  font-family: 'Fraunces', serif;
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 600;
  letter-spacing: -0.5px;
  margin: 0 0 12px;
  color: var(--navy);
}

.page-subtitle {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.2rem, 5vw, 0.9rem);
  font-weight: 500;
  letter-spacing: -0.4px;
  margin: 0 0 12px;
  color: var(--navy);
}

.page-sub {
  font-size: 1rem;
  color: var(--muted);
  max-width: 560px;
  line-height: 1.6;
  margin: 0;
}

/* ── Range selector bar ── */
.custom-range-panel {
  position: sticky;
  top: 104px;
  z-index: 15;
}

.range-bar {
  position: sticky;
  top: 0;
  z-index: 11;
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 0px;
  box-shadow: 0 4px 20px rgba(15,27,46,0.06);
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 16px;
}

.range-bar-inner {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  grid-column: 1;
  grid-row: 1;
}

.range-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.range-btn:hover {
  border-color: var(--c-nifty);
  color: var(--navy);
}

.range-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--paper);
}



@media (max-width: 640px) {
  .range-btn-custom { margin-left: 0; }
}

.custom-range-panel {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  margin: 0 auto;
  margin-bottom: 28px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  max-width: 1180px;
  background: var(--paper);
  border-left: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  border-radius: 14px;
}

.custom-range-panel[hidden] {
  display: none;
}

.custom-range-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.custom-range-panel input[type="date"] {
  font-family: 'Inter', sans-serif;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.custom-range-panel input[type="date"]:disabled,
.apply-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.apply-btn {
  background: var(--c-sp500);
  color: var(--paper);
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.18s var(--ease);
}

.apply-btn:hover { opacity: 0.88; }

.range-context {
  grid-column: 1;
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.last-updated-inline {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: right;
  align-self: start;
  margin: 0;
  grid-column: 2;
  grid-row: 1;
}

.last-updated-inline strong {
  color: var(--navy);
  font-weight: 600;
}

.last-updated-note {
  opacity: 0.65;
}

/* ── Data grid: table + chart ── */
.data-grid {
  display: grid;
  grid-template-columns: minmax(280px, 38%) 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .data-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.panel-title {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 16px;
}

/* ── Return table ── */
.return-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.return-table th {
  text-align: left;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0 10px;
  border-bottom: 1.5px solid var(--border);
}

.return-table .rt-return { text-align: right; }

.return-table td {
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.25s var(--ease);
}

.return-table tbody tr:last-child td { border-bottom: none; }

.rt-market-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
}

.rt-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rt-return-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.98rem;
}

.rt-return-cell.gain { color: var(--gain); }
.rt-return-cell.loss { color: var(--loss); }

.table-fade {
  opacity: 0;
}

/* ── Best performers ── */
.best-performer {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1.5px solid var(--border);
}

.bp-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

.bp-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bp-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.bp-rank {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--border);
  width: 18px;
  flex-shrink: 0;
}

.bp-list li:first-child .bp-rank { color: var(--c-sp500); }

.bp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bp-name {
  flex: 1;
  font-weight: 500;
}

.bp-value {
  font-weight: 700;
}

.bp-value.gain { color: var(--gain); }
.bp-value.loss { color: var(--loss); }

/* ── Chart panel ── */
.chart-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}

.chart-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--cream);
  border-radius: 8px;
  padding: 3px;
}

.mode-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.mode-btn.active {
  background: var(--paper);
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(15,27,46,0.12);
}

/* ── Index picker checkboxes ── */
.index-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border: none;
  margin: 16px 0 20px;
  padding: 0;
}

.index-picker legend {
  width: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 0;
}

.idx-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 13px 7px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--cream);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  user-select: none;
}

.idx-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.idx-chip .idx-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.35;
  transition: opacity 0.18s var(--ease);
}

.idx-chip.checked {
  border-color: currentColor;
  background: var(--paper);
}

.idx-chip.checked .idx-dot { opacity: 1; }

.idx-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Chart canvas ── */


.chart-wrap {
  position: relative;
  width: 100%;
  height: 360px;
  min-height: 260px;
  display: block;          /* ← prevents flex/grid collapsing it */
}

#comparisonChart {
  max-width: 100%;
}

.chart-summary {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1.5px solid var(--border);
}

.chart-summary p {
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 8px;
}

.chart-summary p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.chart-summary-caveat {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
  padding-bottom: 10px;
  margin-bottom: 12px !important;
  border-bottom: 1px dashed var(--border);
}

/* ── Explainer ── */
.explainer {
  margin-top: 32px;
  padding: 20px 24px;
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 14px;
}

.explainer p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
}

.explainer strong { color: var(--navy); }

/* ── Footer ── */
.site-footer {
  background: var(--navy);
  padding: 36px 24px;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  text-align: center;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--paper);
  margin-bottom: 14px;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.footer-nav a {
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  transition: color 0.18s var(--ease);
}

.footer-nav a:hover {
  color: var(--paper);
}

.footer-disclaimer {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  max-width: 480px;
  margin: 0 auto 10px;
  line-height: 1.6;
}

.footer-copy {
  font-size: 0.74rem;
  color: rgba(255,255,255,0.35);
  margin: 0;
}

/* ════════════════════════════════════
   PRIVACY POLICY
════════════════════════════════════ */

.legal-content {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 36px 40px;
  margin: 0 auto 40px;
  max-width: 760px;
}

.legal-content h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--navy);
  margin: 32px 0 12px;
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-content p {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--ink);
  margin: 0 0 14px;
}

.legal-content ul {
  margin: 0 0 14px;
  padding-left: 22px;
}

.legal-content li {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 8px;
}

.legal-content a {
  color: var(--c-sp500);
  text-decoration: underline;
  text-decoration-color: rgba(193,67,42,0.3);
}

.legal-content a:hover {
  text-decoration-color: var(--c-sp500);
}

.legal-content strong {
  color: var(--navy);
  font-weight: 600;
}

.legal-intro {
  text-align: center;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.legal-intro .eyebrow {
  justify-content: center;
}

.legal-intro .page-sub {
  margin-left: auto;
  margin-right: auto;
}

/* ── Mobile tuning ── */

@media (max-width: 640px) {

  .page-intro {
    padding: 24px 0 18px;
  }

  .panel {
    padding: 16px;
  }


.range-bar {
    position: static;
    padding: 8px 10px;
    display: block;
  }

  .range-bar .range-btn {
    font-size: 0.72rem;
    padding: 5px 9px;
  }

  .range-bar .last-updated-inline {
    font-size: 0.68rem;
  }

  .range-bar .range-context {
    font-size: 0.7rem;
    margin-top: 8px;
  }

  .last-updated-inline {
    text-align: left;
    margin-top: 12px;
    margin-bottom: 12px;
  }

.custom-range-panel {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: 0px;
    left: 0;
    right: 0;
    z-index: 15;
    background: var(--paper);
    padding: 6px 10px;
    margin: 0;
    border-bottom: 1.5px solid var(--border);
    box-shadow: 0 4px 12px rgba(15,27,46,0.08);
  }

  .custom-range-panel .range-btn-custom {
    font-size: .92rem;
    padding: 5px 9px;
  }

  .custom-range-panel label {
    font-size: 0.68rem;
    gap: 2px;
  }

  .custom-range-panel input[type="date"] {
    font-size: .75rem;
    padding: 4px 6px;
  }

  .apply-btn {
    font-size: .92rem;
    padding: 5px 10px;
  }

.chart-wrap {
  height: 380px;
  min-height: 380px;
  width: auto;
  margin-left: -40px;
  margin-right: -40px;
}

}

@media (max-height: 480px) and (orientation: landscape) {
  .range-bar {
    position: static;
    margin-bottom: 0;
  }

  .custom-range-panel {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: end;
  }
  .custom-range-panel label,
  .apply-btn {
    width: auto;
  }

    main {
    display: grid;
    grid-template-columns: 42% 1fr;
    grid-template-areas:
      "intro   intro"
      "range   table"
      "custom  table"
      "chart   chart"
      "explain explain";
    gap: 16px;
  }

  .page-intro  { grid-area: intro; }
  .range-bar   { grid-area: range; }
  .custom-range-panel { grid-area: custom; position: static; }
  .data-grid   { display: contents; }   /* lets its children join main's grid */
  .table-panel { grid-area: table; max-width: none; margin: 0; }
  .chart-panel { grid-area: chart; }
  .explainer   { grid-area: explain; margin-top: 0; }

  .chart-wrap {
    height: 300px;
    min-height: 240px;
  }

.range-btn {
    font-size: 0.76rem;
    padding: 6px 10px;
  }

  .custom-range-panel input[type="date"] {
    font-size: 0.78rem;
    padding: 6px 8px;
  }

  .apply-btn {
    font-size: 0.76rem;
    padding: 6px 12px;
  }

  .return-table {
    font-size: 0.85rem;
  }
}