/* paultan.org / JPJ DATA — "asphalt editorial"
   Dark chartbook themed like a Malaysian highway at night:
   asphalt charcoal, brake-light red (paultan.org black/red/grey),
   lane-dash dividers, number-plate section badges, odometer numerals. */

:root {
  --asphalt: #131519;
  --asphalt-2: #181b21;
  --card: #1c2026;
  --card-edge: #2a2f38;
  --ink: #e8e6df;
  --ink-dim: #9aa0ab;
  --ink-faint: #5d6470;
  --pt-red: #f5383e;        /* brightened for dark bg; logo stays brand #EA2127 */
  --pt-red-dim: #94181c;
  --plate-black: #0a0b0d;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Archivo", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth; scroll-padding-top: 70px;
  /* stop iOS Safari inflating text blocks wider than the layout (causes
     horizontal scroll on iPhone that desktop engines never reproduce) */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, #1d2129 0%, transparent 60%),
    var(--asphalt);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* film grain */
.grain {
  position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px;
  background: rgba(19, 21, 25, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-edge);
}
.brand { text-decoration: none; font-weight: 800; letter-spacing: .02em; font-size: 15px; display: flex; align-items: center; }
.brand img { height: 22px; display: block; }
.brand-sep { color: var(--ink-faint); margin: 0 9px; }
.brand-jpj { color: var(--ink-dim); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.topbar-links { display: flex; gap: 20px; }
.topbar-links a {
  color: var(--ink-dim); text-decoration: none; font-size: 13px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; transition: color .15s;
}
.topbar-links a:hover { color: var(--pt-red); }
.langs { display: flex; align-items: center; gap: 5px; color: var(--ink-dim); }
.langs svg { width: 14px; height: 14px; flex: none; }
.langs select {
  appearance: none; -webkit-appearance: none;
  background: transparent; color: var(--ink-dim);
  border: 0; border-radius: 5px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  padding: 3px 14px 3px 2px; cursor: pointer; transition: color .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4'%3E%3Cpath d='M0 0l3.5 4L7 0z' fill='%239aa0ab'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 2px center;
}
.langs select:hover, .langs select:focus { color: var(--ink); outline: none; }
.langs select option { background: var(--card); color: var(--ink); }

/* ---------- hero ---------- */
.hero { max-width: 1060px; margin: 0 auto; padding: 90px 28px 30px; text-align: center; }

.plate {
  display: inline-block; background: var(--plate-black); color: #fff;
  font-family: var(--sans); font-weight: 800; font-stretch: 115%;
  font-size: 12px; letter-spacing: .18em;
  padding: 3px 10px 2px; border-radius: 4px;
  border: 1px solid #33363e; box-shadow: 0 2px 0 #000;
  margin-right: 10px; vertical-align: 1px;
}

.hero-title {
  font-weight: 900; font-stretch: 120%;
  font-size: clamp(44px, 7.2vw, 88px);
  line-height: 1.02; letter-spacing: -.015em;
  margin-bottom: 36px;
  animation: rise .7s .08s ease both;
}

.odo {
  font-family: var(--mono); font-weight: 600;
  font-size: clamp(40px, 6.4vw, 76px);
  letter-spacing: .06em; color: var(--pt-red);
  text-shadow: 0 0 36px rgba(245, 56, 62, .32);
  font-variant-numeric: tabular-nums;
  margin-bottom: 18px;
  animation: rise .7s .16s ease both;
}

.hero-sub { color: var(--ink-dim); max-width: 560px; margin: 0 auto 40px; animation: rise .7s .24s ease both; }
.hero-sub strong { color: var(--ink); }

.hero-spark { animation: rise .8s .32s ease both; }
.chart-spark { height: 130px; }

.hero-hint {
  margin-top: 26px; font-family: var(--mono); font-size: 11px;
  letter-spacing: .3em; color: var(--ink-faint);
  animation: bob 2.2s ease-in-out infinite;
}

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* lane-marking divider */
.lane {
  height: 4px; max-width: 1060px; margin: 30px auto;
  background: repeating-linear-gradient(90deg,
    var(--pt-red-dim) 0 46px, transparent 46px 78px);
  border-radius: 2px; opacity: .5;
}

/* ---------- chapters ---------- */
main { max-width: 1060px; margin: 0 auto; padding: 0 28px; }

.chapter { padding: 72px 0 26px; }

.chapter-head { max-width: 660px; margin-bottom: 30px; }
.chap-kicker {
  font-family: var(--mono); font-size: 12px; letter-spacing: .22em;
  color: var(--ink-dim); margin-bottom: 16px;
}
.chapter h2 {
  font-weight: 900; font-stretch: 118%;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.06; letter-spacing: -.01em; margin-bottom: 14px;
}
.standfirst { color: var(--ink-dim); font-size: 18px; }

/* alternate chapters push right for asymmetry */
.chapter:nth-of-type(even) .chapter-head { margin-left: auto; text-align: right; }

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--asphalt-2) 100%);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
}
.card-title {
  font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-dim); margin: 4px 2px 14px;
}
.card-tools { display: flex; justify-content: flex-end; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }

.chart { height: 440px; width: 100%; }
.chart-half { height: 360px; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.ev-board { margin-top: 22px; }
.ev-board-title { margin: 4px auto 0 2px; }

/* segmented toggle */
.seg { display: inline-flex; border: 1px solid var(--card-edge); border-radius: 8px; overflow: hidden; }
.seg button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-dim); font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  padding: 7px 16px; transition: all .15s;
}
.seg button.on { background: var(--pt-red); color: #fff; font-weight: 600; }
.seg button:not(.on):hover { color: var(--ink); }

/* year picker */
.yearpick { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--ink-dim); }
.yearpick select {
  margin-left: 8px; background: var(--plate-black); color: var(--ink);
  border: 1px solid var(--card-edge); border-radius: 8px;
  font-family: var(--mono); font-size: 13px; padding: 7px 10px;
}

/* ---------- leaderboard ---------- */
.leaderboard { list-style: none; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px 2px; }
.lb-row { display: grid; grid-template-columns: 56px 1fr 110px; align-items: center; gap: 14px; }
.lb-rank {
  font-family: var(--sans); font-weight: 800; font-stretch: 115%;
  background: var(--plate-black); color: #fff; border: 1px solid #33363e;
  border-radius: 4px; text-align: center; padding: 4px 0; font-size: 14px;
  box-shadow: 0 2px 0 #000;
}
.lb-row:first-child .lb-rank { background: var(--pt-red); color: #fff; border-color: var(--pt-red); }
.lb-bar-wrap { position: relative; height: 34px; border-radius: 6px; overflow: hidden; background: rgba(255,255,255,.03); }
.lb-bar {
  position: absolute; inset: 0 auto 0 0; border-radius: 6px;
  background: linear-gradient(90deg, rgba(245,56,62,.32), rgba(245,56,62,.1));
  border-right: 2px solid var(--pt-red);
  transition: width .6s cubic-bezier(.2,.7,.3,1);
}
.lb-name { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 12px; font-weight: 700; font-size: 15px; }
.lb-name small { color: var(--ink-dim); font-weight: 500; margin-right: 8px; }
.lb-n { font-family: var(--mono); font-size: 14px; color: var(--ink-dim); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- explorer ---------- */
.explorer-tools { justify-content: flex-start; align-items: flex-start; }
.search-wrap { position: relative; flex: 0 0 300px; }
#m-search {
  width: 100%; background: var(--plate-black); border: 1px solid var(--card-edge);
  color: var(--ink); border-radius: 9px; padding: 10px 14px;
  /* 16px minimum: iOS Safari zooms the viewport into focused inputs below 16px */
  font-family: var(--sans); font-size: 16px; outline: none; transition: border-color .15s;
}
#m-search:focus { border-color: var(--pt-red); }
.search-results {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  list-style: none; background: var(--card); border: 1px solid var(--card-edge);
  border-radius: 10px; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.6);
  max-height: 320px; overflow-y: auto;
}
.search-results li {
  padding: 9px 14px; cursor: pointer; font-size: 14px;
  display: flex; justify-content: space-between; gap: 10px;
}
.search-results li:hover { background: rgba(245, 56, 62, .12); }
.search-results li small { color: var(--ink-faint); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.search-results li b { color: var(--ink-dim); font-weight: 500; margin-right: 6px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 3px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13px;
  background: var(--plate-black); border: 1px solid var(--card-edge);
  padding: 8px 12px; border-radius: 8px;
}
.chip .dot { width: 10px; height: 10px; border-radius: 3px; }
.chip button {
  appearance: none; background: none; border: 0; color: var(--ink-faint);
  font-size: 15px; cursor: pointer; line-height: 1; padding: 0 0 0 2px;
}
.chip button:hover { color: #ff5d73; }

.colour-mixes { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.mix-row { display: grid; grid-template-columns: 170px 1fr; gap: 14px; align-items: center; }
.mix-label { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); text-align: right; }
.mix-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; border: 1px solid var(--card-edge); }
.mix-bar span { display: block; height: 100%; min-width: 1px; transition: filter .12s; }
.mix-bar span:hover { filter: brightness(1.25); }

/* cursor tooltip for colour-mix segments */
.mix-tip {
  display: none; position: fixed; z-index: 60; pointer-events: none;
  background: #1d2026; border: 1px solid #33363e; border-radius: 7px;
  padding: 6px 10px; font-family: var(--mono); font-size: 12px; color: var(--ink);
  white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.mix-tip .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }

/* note below a chart explaining the data */
.chart-note {
  margin-top: 16px; padding: 12px 16px;
  font-size: 13.5px; line-height: 1.55; color: var(--ink-dim);
  background: rgba(255, 255, 255, .025);
  border-left: 3px solid var(--pt-red-dim); border-radius: 0 8px 8px 0;
}
.chart-note em { font-style: normal; color: var(--ink); font-family: var(--mono); font-size: 12.5px; }

/* ---------- footer ---------- */
.foot { max-width: 1060px; margin: 60px auto 0; padding: 0 28px 70px; color: var(--ink-dim); font-size: 14px; }
.foot .lane { margin: 0 0 36px; max-width: none; }
.foot p { max-width: 760px; margin-bottom: 14px; }
.foot a { color: var(--pt-red); text-decoration: none; }
.foot-brand { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; color: var(--ink-faint); }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .duo { grid-template-columns: 1fr; }
  .topbar-links { display: none; }
  .chapter:nth-of-type(even) .chapter-head { margin-left: 0; text-align: left; }
  .chart { height: 360px; }
  .mix-row { grid-template-columns: 1fr; gap: 6px; }
  .mix-label { text-align: left; }
  .lb-row { grid-template-columns: 44px 1fr 84px; }
  .search-wrap { flex: 1 1 100%; }
}
