/* Tokens: structure from the RKO spec, colors from the SCSF emblem (navy, saffron, red). */
:root {
  --font-family-primary: "DM Sans", "Kantumruy Pro", sans-serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-h3: 1.25rem;
  --font-size-h2: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --font-size-h1: clamp(2rem, 1.4rem + 2.6vw, 3.25rem);
  --line-height-base: 1.7;
  --line-height-km: 1.9;

  --color-text-primary: #1f2766;   /* navy, 13.9:1 on white */
  --color-text-body: #4a5285;      /* 7.4:1 on white */
  --color-text-inverse: #ffffff;
  --color-accent-saffron: #f2a516; /* decoration only, never text on light */
  --color-accent-red: #c8202d;     /* 5.9:1 on white */
  --color-surface-base: #ffffff;
  --color-surface-muted: #fbf6ea;  /* cream from the emblem */
  --color-border: #dddddd;
  --color-focus: #1f2766;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4.5rem;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-1: rgba(55, 65, 154, 0.1) 0 8px 26px 0;
  --shadow-2: rgba(55, 65, 154, 0.07) 0 4px 16px 0;
  --motion-fast: 200ms;
  --motion-normal: 500ms;
  --motion-slow: 600ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --container: 72rem;
}

/* Bilingual: html[lang] decides which spans show. */
html[lang="km"] body [lang="en"],
html[lang="en"] body [lang="km"] { display: none; }
html[lang="km"] body { line-height: var(--line-height-km); }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0;
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text-body);
  background: var(--color-surface-base);
}
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { color: var(--color-text-primary); line-height: 1.3; margin: 0 0 var(--space-3); overflow-wrap: anywhere; }
h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-text-primary); text-underline-offset: 3px; }
a:hover { color: var(--color-accent-red); }

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

.skip-link {
  position: absolute; left: var(--space-3); top: -4rem; z-index: 10;
  padding: var(--space-2) var(--space-3);
  background: var(--color-text-primary); color: var(--color-text-inverse);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-3); color: var(--color-text-inverse); }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--space-3); }
.narrow { max-width: 48rem; }
.narrow-text { max-width: 48rem; }
.about { font-size: var(--font-size-lg); }
.about p { text-wrap: pretty; }
.about-intro { max-width: 60rem; margin-bottom: var(--space-5); }
.about .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.center { text-align: center; }

/* Header: triple stripe echoes the emblem's rings */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--color-surface-base);
  box-shadow: 0 2px 0 var(--color-text-primary), 0 4px 0 var(--color-accent-saffron), 0 6px 0 var(--color-accent-red);
}
.header-inner { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding-block: var(--space-2); }
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; font-weight: 700; margin-right: auto; }
.brand img { width: 48px; height: 48px; }
.nav-list { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: inline-block; min-height: 44px; padding: var(--space-2) var(--space-1);
  text-decoration: none; font-weight: 500; font-size: var(--font-size-sm);
}
.nav-list a:hover { text-decoration: underline; }

.lang-toggle, .btn {
  min-height: 44px; padding: var(--space-2) var(--space-4);
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-pill); border: 2px solid var(--color-text-primary);
  transition: background-color var(--motion-fast), color var(--motion-fast);
}
.lang-toggle { background: var(--color-surface-base); color: var(--color-text-primary); padding-inline: var(--space-3); }
.lang-toggle:hover { background: var(--color-surface-muted); }
.lang-toggle:active, .btn:active { transform: translateY(1px); }

@media (max-width: 720px) {
  .site-header { position: static; } /* wrapped nav is too tall to pin on phones */
  nav { order: 3; width: 100%; }
}

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn-primary { background: var(--color-text-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-accent-red); border-color: var(--color-accent-red); color: var(--color-text-inverse); }
.btn-secondary { background: transparent; color: var(--color-text-primary); }
.btn-secondary:hover { background: var(--color-surface-muted); color: var(--color-text-primary); }

/* Sections */
.section { padding-block: var(--space-7); }
.section-muted { background: var(--color-surface-muted); }
.eyebrow {
  margin-bottom: var(--space-2);
  color: var(--color-accent-red); font-weight: 700; font-size: var(--font-size-sm);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.hero-tag {
  display: block; margin-block: var(--space-2);
  color: var(--color-accent-red); font-weight: 700; font-size: 1.375rem; line-height: 1.5;
}
.hero-tag:lang(en) { font-size: var(--font-size-lg); letter-spacing: 0.06em; text-transform: uppercase; }
/* Wider screens: English tag sits on the title's last line; phones keep it below */
@media (min-width: 721px) {
  .hero-tag:lang(en) { display: inline-block; margin: 0 0 0 var(--space-2); }
}
.lead { font-size: var(--font-size-lg); max-width: 40rem; }

.hero { padding-block: var(--space-6); background: var(--color-surface-muted); }
.hero-inner { display: grid; gap: var(--space-5); align-items: center; grid-template-columns: 1fr; }
@media (min-width: 860px) {
  .hero-inner { grid-template-columns: 1fr 1fr; }
}

/* Founders: two portraits side by side, second one offset for rhythm */
.founders { margin: 0; justify-self: center; width: min(100%, 34rem); }
.founders-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); align-items: start;
  transition: grid-template-columns var(--motion-normal) var(--ease-out);
}
.founder { border-radius: var(--radius-md); cursor: zoom-in; transition: margin-top var(--motion-normal) var(--ease-out), opacity var(--motion-normal) var(--ease-out); }
.founder img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: 60% top;
  background: var(--color-surface-base);
  border-radius: var(--radius-md);
  border-bottom: 6px solid var(--color-accent-saffron);
  box-shadow: var(--shadow-2);
  transition: box-shadow var(--motion-normal) var(--ease-out);
}
.founder:first-child img { object-position: 50% 18%; }
.founder:last-child { margin-top: var(--space-6); }
.founder:last-child img { border-bottom-color: var(--color-accent-red); }

/* Hover, keyboard focus or tap: that portrait grows into the big card */
.founder:is(:hover, :focus) { opacity: 1; }
.founder:is(:hover, :focus) img { box-shadow: var(--shadow-1), 0 0 0 4px var(--color-surface-base); }
.founders-pair:has(.founder:first-child:is(:hover, :focus)) { grid-template-columns: 2.4fr 1fr; }
.founders-pair:has(.founder:last-child:is(:hover, :focus)) { grid-template-columns: 1fr 2.4fr; }
.founders-pair:has(.founder:is(:hover, :focus)) .founder:not(:hover, :focus) { opacity: 0.6; }
.founders-pair:has(.founder:last-child:is(:hover, :focus)) .founder:last-child { margin-top: 0; }
.founders figcaption {
  margin-top: var(--space-3); text-align: center;
  font-weight: 700; color: var(--color-text-primary);
}

/* Emblem: navy band so it stands apart from the cream/white rhythm */
.section-brand { background: var(--color-text-primary); color: var(--color-text-inverse); }
.section-brand h2, .section-brand h3 { color: var(--color-text-inverse); }
.section-brand .eyebrow { color: var(--color-accent-saffron); } /* 7.6:1 on navy */
.emblem { align-items: center; }
/* Layers: figure (scroll reveal + ground shadow) > .emblem-float (idle bob) > img (hover lift).
   Each layer animates its own property, so nothing snaps when hover starts or ends. */
.emblem-figure { position: relative; margin: 0 0 var(--space-5); justify-self: center; width: min(100%, 30rem); }
.emblem-figure::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: -36px; height: 28px;
  border-radius: 50%; background: rgba(0, 0, 0, 0.5); filter: blur(14px);
}
.emblem-float { position: relative; z-index: 1; }
/* White disc hides the image's square white corners against the navy */
.emblem-figure img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  padding: var(--space-3); background: var(--color-surface-base); border-radius: 50%;
  cursor: default;
  transition: translate 700ms var(--ease-out), scale 700ms var(--ease-out), rotate 700ms var(--ease-out);
}
.emblem-figure:hover img { translate: 0 -20px; scale: 1.06; rotate: -3deg; }
.emblem-list { list-style: none; padding: 0; margin: var(--space-4) 0 0; display: grid; gap: var(--space-4); }
.emblem-list li { padding-left: var(--space-4); border-left: 4px solid var(--color-accent-saffron); }
.emblem-list h3 { font-size: var(--font-size-lg); margin-bottom: var(--space-1); }
.emblem-list p { margin: 0; }

.split { display: grid; gap: var(--space-5); align-items: start; }
@media (min-width: 860px) { .split { grid-template-columns: 1fr 1fr; } }

/* Cards and grids */
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); list-style: none; padding: 0; margin: 0; }
.card {
  margin: 0; overflow: hidden;
  background: var(--color-surface-base);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
}
#events .card img { aspect-ratio: 3 / 2; object-fit: cover; object-position: top; width: 100%; }
.card-pad { padding: var(--space-4); border-top: 4px solid var(--color-accent-saffron); }
.card-pad p { margin: 0; }
.card figcaption { padding: var(--space-3); font-size: var(--font-size-sm); color: var(--color-text-primary); font-weight: 500; }

.partner { margin: var(--space-4) 0 0; }
.partner img { width: min(100%, 22rem); border-radius: var(--radius-md); background: var(--color-surface-base); border: 1px solid var(--color-border); }
.partner figcaption { margin-top: var(--space-2); font-size: var(--font-size-sm); color: var(--color-text-body); }

/* Definition lists (roster, contact) */
.roster { margin: var(--space-4) 0 0; border-top: 1px solid var(--color-border); }
.roster > div { display: grid; gap: var(--space-1) var(--space-4); padding-block: var(--space-3); border-bottom: 1px solid var(--color-border); }
@media (min-width: 600px) { .roster > div { grid-template-columns: 14rem 1fr; } }
.roster dt { font-weight: 700; color: var(--color-text-primary); }
.roster dd { margin: 0; overflow-wrap: anywhere; }

.site-footer { padding-block: var(--space-5); background: var(--color-text-primary); color: var(--color-text-inverse); font-size: var(--font-size-sm); }
.site-footer p { margin: 0; }

/* Motion: all of it lives behind no-preference, so reduced-motion users get a static page */
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

@media (prefers-reduced-motion: no-preference) {
  /* Hero entrance, staggered */
  .hero-copy > * { animation: rise var(--motion-slow) var(--ease-out) both; }
  .hero-copy > :nth-child(2) { animation-delay: 80ms; }
  .hero-copy > :nth-child(3) { animation-delay: 160ms; }
  .hero-copy > :nth-child(4) { animation-delay: 240ms; }
  .founder { animation: rise 800ms var(--ease-out) both; animation-delay: 200ms; }
  .founder:last-child { animation-delay: 350ms; }

  /* Emblem bobs; its ground shadow shrinks as it rises */
  @keyframes float { 50% { translate: 0 -22px; } }
  @keyframes float-shadow { 50% { scale: 0.7; opacity: 0.5; } }
  .emblem-float { animation: float 4s ease-in-out infinite; }
  .emblem-figure::after { animation: float-shadow 4s ease-in-out infinite; }
  /* Hover freezes the bob in place; it resumes from the same spot on leave */
  .emblem-figure:hover .emblem-float,
  .emblem-figure:hover::after { animation-play-state: paused; }
  /* Buttons lift slightly */
  .btn { transition: background-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast); }
  .btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }

  /* Scroll reveal: native scroll-driven animation; unsupported browsers just show content */
  @supports (animation-timeline: view()) {
    .section h2, .section .card, .about-intro, .roster > div, .partner, .emblem-figure, .emblem-list li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 35%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
