/* ============================================================
   Shared foundation — every page in the site loads this first.
   Tokens, the background video, the glass surfaces, the nav,
   the chamfered button, the vertical rules and the slide-in menu.
   Page-specific rules live in styles.css / app.css.
   ============================================================ */

:root {
  color-scheme: light;

  --ink:      #000;
  --ink-2:    rgba(0, 0, 0, 0.6);
  --ink-3:    rgba(0, 0, 0, 0.55);
  --hair:     rgba(0, 0, 0, 0.1);
  --hair-2:   rgba(0, 0, 0, 0.2);

  /* Frosted panel: opaque enough to read dense text over moving video. */
  --panel:      rgba(255, 255, 255, 0.58);
  --panel-2:    rgba(255, 255, 255, 0.40);
  --panel-solid:rgba(255, 255, 255, 0.86);
  --panel-line: rgba(47, 47, 47, 0.15);
  --panel-blur: blur(20px) saturate(140%);

  --frost:      rgba(255, 255, 255, 0.05);
  --frost-hover:rgba(255, 255, 255, 0.10);
  --frost-ring: inset 0 1.5px 2px rgba(255, 255, 255, 0.3),
                inset 0 -1px 2px rgba(0, 0, 0, 0.15);

  --video-filter: none;
  --menu-bg: #f5f4f0;
  /* Shown before the video decodes, and if it never does. Must track the
     theme or dark mode renders light text on a pale ground. */
  --page-bg: #c2ccd3;

  /* Course identity — an 8-slot categorical palette, validated for
     colour-vision separation against both surfaces. Append, never insert. */
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100;
  --s5:#e87ba4; --s6:#008300; --s7:#4a3aa7; --s8:#e34948;

  --warn:#8A5000; --warn-bg:rgba(255,236,204,.75); --warn-line:rgba(138,80,0,.32);
  --done:#14663F;
  --bar-lo:#B7D3F6; --bar-mid:#5598E7; --bar-hi:#1C5CAB;

  --sans: 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
}

/* The video is bright, so dark mode dims it rather than fighting it —
   both pages stay one world, just lit differently. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink:      #F4F5F7;
    --ink-2:    rgba(244, 245, 247, 0.62);
    --ink-3:    rgba(244, 245, 247, 0.56);
    --hair:     rgba(255, 255, 255, 0.12);
    --hair-2:   rgba(255, 255, 255, 0.22);
    --panel:      rgba(16, 18, 22, 0.58);
    --panel-2:    rgba(16, 18, 22, 0.40);
    --panel-solid:rgba(16, 18, 22, 0.88);
    --panel-line: rgba(255, 255, 255, 0.14);
    --frost:      rgba(255, 255, 255, 0.04);
    --frost-hover:rgba(255, 255, 255, 0.09);
    --frost-ring: inset 0 1.5px 2px rgba(255, 255, 255, 0.14),
                  inset 0 -1px 2px rgba(0, 0, 0, 0.4);
    --video-filter: brightness(0.34) saturate(0.72) contrast(1.05);
    --menu-bg: #14161a;
    --page-bg: #0d0f12;
    --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
    --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
    --warn:#E0A94E; --warn-bg:rgba(224,169,78,.16); --warn-line:rgba(224,169,78,.34);
    --done:#54B98A;
    --bar-lo:#184F95; --bar-mid:#3987e5; --bar-hi:#9EC5F4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink:      #F4F5F7;
  --ink-2:    rgba(244, 245, 247, 0.62);
  --ink-3:    rgba(244, 245, 247, 0.56);
  --hair:     rgba(255, 255, 255, 0.12);
  --hair-2:   rgba(255, 255, 255, 0.22);
  --panel:      rgba(16, 18, 22, 0.58);
  --panel-2:    rgba(16, 18, 22, 0.40);
  --panel-solid:rgba(16, 18, 22, 0.88);
  --panel-line: rgba(255, 255, 255, 0.14);
  --frost:      rgba(255, 255, 255, 0.04);
  --frost-hover:rgba(255, 255, 255, 0.09);
  --frost-ring: inset 0 1.5px 2px rgba(255, 255, 255, 0.14),
                inset 0 -1px 2px rgba(0, 0, 0, 0.4);
  --video-filter: brightness(0.34) saturate(0.72) contrast(1.05);
  --menu-bg: #14161a;
  --page-bg: #0d0f12;
  --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
  --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
  --warn:#E0A94E; --warn-bg:rgba(224,169,78,.16); --warn-line:rgba(224,169,78,.34);
  --done:#54B98A;
  --bar-lo:#184F95; --bar-mid:#3987e5; --bar-hi:#9EC5F4;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  width: 100%;
  background: var(--page-bg);
  color: var(--ink);
  overflow-x: hidden;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 300; letter-spacing: -0.025em; text-wrap: balance; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.icon { flex: none; }

/* ---------- background video ---------- */
.bg-video {
  position: fixed; top: 0; left: 0;
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 1;
  pointer-events: none;
  filter: var(--video-filter);
}
.glass-defs { position: absolute; width: 0; height: 0; pointer-events: none; }

/* ---------- refractive glass ----------
   glass-card.js writes the duplicate's position every frame. */
.glass-dup { position: absolute; left: 0; top: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.glass-dup canvas { position: absolute; inset: 0; width: 100%; height: 100%; filter: url(#liquid-glass-refraction); }
.glass-frost {
  position: absolute; inset: 0; z-index: 1;
  border-radius: inherit; pointer-events: none;
  background: var(--frost);
  box-shadow: var(--frost-ring);
  transition: background 400ms;
}
[data-glass-card]:hover > .glass-frost { background: var(--frost-hover); }

/* ---------- frosted panel: the workhorse surface ---------- */
.pane {
  position: relative;
  background: var(--panel);
  -webkit-backdrop-filter: var(--panel-blur);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--panel-line);
  border-radius: 20px;
}

/* ---------- vertical rules (>=768px) ---------- */
.rule { position: fixed; top: 0; bottom: 0; z-index: 1; display: none; flex-direction: column; align-items: center; pointer-events: none; }
.rule--left  { left: 1.25rem; }
.rule--right { right: 1.25rem; }
.rule__seg { width: 1px; background: var(--hair-2); }
.rule__seg--end { height: 15%; }
.rule__seg--mid { flex: 1 1 0%; }
.rule__plus { font-size: 0.75rem; line-height: 1; color: var(--ink-3); padding: 0.25rem 0; }
@media (min-width: 768px) { .rule { display: flex; } }

/* ---------- navbar ---------- */
.nav { position: relative; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem; }
.nav__item {
  display: inline-flex; align-items: center; gap: 0.625rem;
  color: var(--ink); background: none; border: 0; text-decoration: none;
  cursor: pointer; pointer-events: auto; transition: opacity 300ms;
}
.nav__item:hover { opacity: 0.6; }
.nav__label { font-size: 0.875rem; line-height: 1.25rem; letter-spacing: 0.025em; white-space: nowrap; }
.nav__label--menu { display: none; }
.nav__dot { width: 8px; height: 8px; border-radius: 9999px; background: var(--ink); flex: none; }
@media (min-width: 640px) { .nav { padding: 1.25rem 1.5rem; } .nav__label--menu { display: inline; } }
@media (min-width: 768px) { .nav { padding: 1.5rem 3rem; } }

/* ---------- chamfered button ---------- */
.chamfer {
  position: relative; display: inline-flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 44px; padding: 0 1.25rem;
  color: var(--ink); text-decoration: none; background: none; border: 0;
  cursor: pointer; pointer-events: auto; transition: opacity 300ms;
}
.chamfer:hover { opacity: 0.7; }
.chamfer__glass {
  position: absolute; inset: 0;
  background: var(--panel-2);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--hair-2);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.chamfer__outline { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chamfer__label { position: relative; font-size: 0.75rem; letter-spacing: 0.025em; white-space: nowrap; }
.chamfer .icon { position: relative; }
@media (min-width: 640px) {
  .chamfer { height: 48px; padding: 0 1.5rem; }
  .chamfer__label { font-size: 0.875rem; }
}

/* ---------- slide-in menu ---------- */
.menu { position: fixed; inset: 0; z-index: 50; visibility: hidden; pointer-events: none;
        transition: visibility 0s linear 500ms; }
.menu.is-open { visibility: visible; pointer-events: auto; transition-delay: 0s; }

.menu__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4);
                  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
                  opacity: 0; transition: opacity 500ms; }
.menu.is-open .menu__backdrop { opacity: 1; }

.menu__panel { position: absolute; top: 0; left: 0; display: flex; flex-direction: column;
               width: 100%; height: 100%; padding: 1.5rem 2rem; background: var(--menu-bg);
               overflow-y: auto;
               transform: translateX(-100%);
               transition: transform 500ms var(--ease); }
.menu.is-open .menu__panel { transform: translateX(0); }
@media (min-width: 640px) { .menu__panel { width: 380px; padding: 1.5rem 2.5rem; } }

.menu__close { display: inline-flex; align-items: center; gap: 0.625rem; align-self: flex-start;
               margin-bottom: 3rem; background: none; border: 0; font-size: 0.875rem;
               color: var(--ink); cursor: pointer; transition: opacity 300ms; }
.menu__close:hover { opacity: 0.6; }

.menu__nav { display: flex; flex-direction: column; }
.menu__link { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0;
              border-bottom: 1px solid var(--hair); color: var(--ink); text-decoration: none;
              background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%;
              text-align: left; cursor: pointer;
              opacity: 0; transform: translateY(20px); transition: opacity 500ms, transform 500ms; }
.menu__linkText { font-size: 1.5rem; font-weight: 300; letter-spacing: -0.025em; transition: transform 300ms; }
.menu__link:hover .menu__linkText { transform: translateX(8px); }
.menu__link[aria-current="true"] .menu__linkText { font-weight: 400; }
.menu__link[aria-current="true"]::before { content: ""; position: absolute; left: 0; width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
.menu__arrow { opacity: 0; transform: translateX(8px); transition: opacity 300ms, transform 300ms; }
.menu__link:hover .menu__arrow { opacity: 1; transform: translateX(0); }
@media (min-width: 640px) { .menu__linkText { font-size: 1.875rem; } }

.menu.is-open .menu__link { opacity: 1; transform: translateY(0); }
.menu.is-open .menu__link:nth-child(1) { transition-delay: 150ms; }
.menu.is-open .menu__link:nth-child(2) { transition-delay: 210ms; }
.menu.is-open .menu__link:nth-child(3) { transition-delay: 270ms; }
.menu.is-open .menu__link:nth-child(4) { transition-delay: 330ms; }
.menu.is-open .menu__link:nth-child(5) { transition-delay: 390ms; }
.menu.is-open .menu__link:nth-child(6) { transition-delay: 450ms; }
.menu.is-open .menu__link:nth-child(7) { transition-delay: 510ms; }

.menu__foot { margin-top: auto; padding: 1.5rem 0 2rem; border-top: 1px solid var(--hair);
              opacity: 0; transform: translateY(20px); transition: opacity 500ms, transform 500ms; }
.menu.is-open .menu__foot { opacity: 1; transform: translateY(0); transition-delay: 600ms; }
.menu__footLabel { display: block; margin-bottom: 0.75rem; font-size: 0.75rem; text-transform: uppercase;
                   letter-spacing: 0.025em; color: var(--ink-3); }
.menu__mail { font-size: 0.875rem; color: var(--ink-2); text-decoration: none; transition: color 300ms; }
.menu__mail:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
