/* Olympiad Malaysia — portal stylesheet
   Tokens → base → layout → components → motion → responsive */

:root {
  --paper: #F3F5F9;
  --surface: #FFFFFF;
  --ink: #12203A;
  --ink-soft: #4B5670;
  --rule: #D9DEE8;
  --gold: #C9A227;

  --font: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 8px;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol { margin: 0; }

a { color: inherit; }

img { display: block; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.nav {
  display: flex;
  gap: clamp(16px, 2.5vw, 32px);
  font-size: 15px;
  font-weight: 500;
}

.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding-block: 6px;
  border-bottom: 2px solid transparent;
}

.nav a:hover { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- masthead ---------- */

.masthead { padding-block: clamp(48px, 8vw, 104px) clamp(32px, 4vw, 56px); }

.masthead__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: end;
  gap: 24px clamp(32px, 5vw, 72px);
}

.masthead__title {
  font-size: clamp(38px, 6vw, 76px);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.028em;
  max-width: 14ch;
  font-variation-settings: "opsz" 96;
}

.masthead__lead {
  max-width: 44ch;
  font-size: clamp(17px, 1.35vw, 19px);
  line-height: 1.5;
  color: var(--ink-soft);
  padding-bottom: 6px;
}

/* ---------- tiles ---------- */

.olympiads { padding-block: 8px clamp(56px, 8vw, 112px); }

.tiles {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}

.tile { display: flex; }

/* Each tile is a neutral plate; the official logo supplies the colour.
   The olympiad hue is kept to a hairline at the top and the link text. */
.tile__link {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 28px;
  min-height: 292px;
  padding: 24px 22px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--hue);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.tile__logo {
  height: 72px;
  display: flex;
  align-items: center;
}

.tile__logo img {
  width: auto;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.tile__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.tile__name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.tile__meta {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.tile__cta {
  margin-top: auto;
  padding-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: color-mix(in oklab, var(--hue) 70%, var(--ink));
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color .18s var(--ease);
}

.tile__cta svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile__link:hover,
.tile__link:focus-visible {
  border-color: var(--hue);
  box-shadow: 0 10px 28px -14px color-mix(in oklab, var(--hue) 55%, transparent);
}

.tile__link:hover .tile__cta,
.tile__link:focus-visible .tile__cta { text-decoration-color: currentColor; }

/* ---------- shared section styles ---------- */

.section__title {
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 48;
}

.section__lead {
  margin-top: 14px;
  max-width: 60ch;
  color: var(--ink-soft);
}

/* ---------- compare table ---------- */

.compare {
  padding-block: clamp(56px, 8vw, 96px);
  background: var(--surface);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.table-scroll {
  margin-top: 32px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.compare__table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 15px;
}

.compare__table th,
.compare__table td {
  text-align: left;
  vertical-align: middle;
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--rule);
}

.compare__table thead th {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 14px;
  padding-top: 0;
  vertical-align: bottom;
}

.compare__table tbody th {
  font-weight: 700;
  white-space: nowrap;
}

.compare__table tbody tr:last-child th,
.compare__table tbody tr:last-child td { border-bottom: 0; }

.compare__table a {
  color: var(--ink);
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.compare__table a:hover { text-decoration-color: var(--ink); }

.table__mark {
  display: inline-flex;
  align-items: center;
  width: 72px;
  height: 30px;
  margin-right: 14px;
  vertical-align: middle;
}

.table__mark img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: left center;
}

/* ---------- pathway ---------- */

.pathway { padding-block: clamp(56px, 8vw, 96px); }

.steps {
  list-style: none;
  padding: 0;
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.step {
  padding-top: 20px;
  border-top: 2px solid var(--ink);
}

.step__num {
  display: block;
  font-size: 44px;
  font-weight: 300;
  line-height: 1;
  color: var(--gold);
  font-variation-settings: "opsz" 96;
}

.step__title {
  margin-top: 14px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.step__text {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 16px;
}

/* ---------- about ---------- */

.about {
  padding-block: clamp(56px, 8vw, 96px);
  background: var(--surface);
  border-top: 1px solid var(--rule);
}

.about__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  align-items: start;
}

.about__note {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--rule);
}

.about__note h3 {
  font-size: 17px;
  font-weight: 700;
}

.about__note p {
  margin-top: 8px;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ---------- footer ---------- */

.footer {
  background: var(--ink);
  color: #fff;
  padding-block: 40px;
}

.footer__inner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 20px 40px;
}

.footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 20px;
  font-size: 14px;
}

.footer__links a {
  color: rgba(255, 255, 255, .78);
  text-decoration: none;
}

.footer__links a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

.footer__copy {
  grid-column: 1 / -1;
  font-size: 13px;
  color: rgba(255, 255, 255, .6);
}

/* ---------- motion: one page-load moment ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.masthead__title,
.masthead__lead {
  animation: rise .55s var(--ease) both;
}

.masthead__lead { animation-delay: .08s; }

.tile {
  animation: rise .5s var(--ease) both;
  animation-delay: calc(.16s + var(--i) * 45ms);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .masthead__title, .masthead__lead, .tile { animation: none; }
  .tile__link, .tile__cta { transition: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .masthead__grid { grid-template-columns: 1fr; align-items: start; }
  .masthead__lead { max-width: 58ch; padding-bottom: 0; }
  .steps { grid-template-columns: 1fr; gap: 24px; }
  .about__grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 720px) {
  .topbar__inner { flex-wrap: wrap; padding-block: 14px 8px; gap: 8px 24px; }
  .nav { width: 100%; gap: 20px; }
  .footer__inner { grid-template-columns: 1fr; }
  .footer__links { justify-content: flex-start; }
}

/* Comparison table stacks into one block per olympiad on small screens */
@media (max-width: 640px) {
  .compare__table { min-width: 0; }
  .compare__table thead { display: none; }
  .compare__table tbody tr {
    display: block;
    padding-block: 16px;
    border-bottom: 1px solid var(--rule);
  }
  .compare__table tbody tr:last-child { border-bottom: 0; }
  .compare__table tbody th,
  .compare__table tbody td {
    display: block;
    padding: 0;
    border: 0;
    white-space: normal;
  }
  .compare__table tbody th {
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    font-size: 16px;
  }
  .compare__table tbody td {
    display: grid;
    grid-template-columns: 9em 1fr;
    gap: 12px;
    padding-block: 3px;
  }
  .compare__table tbody td::before {
    content: attr(data-label);
    color: var(--ink-soft);
    font-size: 14px;
  }
}

@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr; }
  .tile__link { min-height: 0; gap: 22px; }
}
