/* ==========================================================================
   flavien.tech: design tokens + shared components
   Monochrome, high-contrast, command-center aesthetic.
   ========================================================================== */

@import url('https://api.fontshare.com/v2/css?f[]=switzer@400,500,600,700,800&f[]=satoshi@400,500,600,700&display=swap');

:root {
  /* ---- Type scale ---- */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);
  --text-hero: clamp(2.75rem, 0.5rem + 6.5vw, 7.25rem);

  /* ---- Spacing (4px base) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* ---- Radius: sharp, near-square ---- */
  --radius-sm: 1px;
  --radius-md: 2px;
  --radius-lg: 2px;
  --radius-full: 2px;

  /* ---- Motion ---- */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Fonts ---- */
  --font-display: 'Switzer', 'Inter', -apple-system, sans-serif;
  --font-body: 'Satoshi', 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* ---- Content widths ---- */
  --content-narrow: 640px;
  --content-default: 1000px;
  --content-wide: 1280px;
  --content-full: 100%;
}

/* ---- DARK (default / brand identity) ---- */
:root,
[data-theme='dark'] {
  --color-bg: #060606;
  --color-surface: #0c0c0c;
  --color-surface-2: #111111;
  --color-surface-offset: #161616;
  --color-surface-offset-2: #1c1c1c;
  --color-surface-dynamic: #202020;
  --color-divider: rgba(255, 255, 255, 0.09);
  --color-border: rgba(255, 255, 255, 0.14);
  --color-border-strong: rgba(255, 255, 255, 0.28);

  --color-text: #f2f2f0;
  --color-text-muted: #9a9a96;
  --color-text-faint: #5c5c59;
  --color-text-inverse: #060606;

  --color-primary: #ffffff;
  --color-primary-hover: #d4d4d0;
  --color-primary-active: #b8b8b4;
  --color-primary-highlight: rgba(255, 255, 255, 0.1);

  --color-error: #ff4d4d;
  --color-error-bg: #1a0505;
  --color-error-border: rgba(255, 77, 77, 0.45);
  --color-error-highlight: rgba(255, 77, 77, 0.12);

  --color-success: #7dd48a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
}

/* ---- LIGHT (accessibility toggle, still monochrome/severe) ---- */
[data-theme='light'] {
  --color-bg: #f2f1ee;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbfa;
  --color-surface-offset: #e9e8e4;
  --color-surface-offset-2: #e0dfda;
  --color-surface-dynamic: #d6d5cf;
  --color-divider: rgba(10, 10, 10, 0.1);
  --color-border: rgba(10, 10, 10, 0.16);
  --color-border-strong: rgba(10, 10, 10, 0.32);

  --color-text: #0a0a0a;
  --color-text-muted: #55554f;
  --color-text-faint: #8a8a83;
  --color-text-inverse: #f2f1ee;

  --color-primary: #0a0a0a;
  --color-primary-hover: #2a2a28;
  --color-primary-active: #3d3d3a;
  --color-primary-highlight: rgba(10, 10, 10, 0.08);

  --color-error: #b32424;
  --color-error-bg: #f8e6e6;
  --color-error-border: rgba(179, 36, 36, 0.4);
  --color-error-highlight: rgba(179, 36, 36, 0.1);

  --color-success: #2c6e39;

  --shadow-sm: 0 1px 2px rgba(20, 20, 15, 0.08);
  --shadow-md: 0 8px 24px rgba(20, 20, 15, 0.1);
  --shadow-lg: 0 20px 48px rgba(20, 20, 15, 0.14);
}

/* ==========================================================================
   Base type
   ========================================================================== */

body {
  background: var(--color-bg);
  background-image:
    linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg) 100%);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

p, li {
  max-width: 68ch;
}

a {
  color: var(--color-text);
  text-decoration: none;
}

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 1px;
  background: var(--color-text-muted);
  display: inline-block;
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Layout helpers
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-16));
}

.wrap--default {
  max-width: var(--content-default);
}

.section {
  padding-block: clamp(var(--space-16), 8vw, var(--space-32));
  border-bottom: 1px solid var(--color-divider);
}

.section--tight {
  padding-block: clamp(var(--space-10), 5vw, var(--space-20));
}

.section:last-of-type {
  border-bottom: none;
}

.grid {
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 900px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--12 { grid-template-columns: repeat(12, 1fr); }
}

/* ==========================================================================
   Reveal-on-scroll (opacity/clip-path only, no layout shift)
   ========================================================================== */

.reveal {
  opacity: 1;
}

@supports (animation-timeline: view()) {
  .reveal {
    opacity: 0;
    animation: reveal-fade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 55%;
  }
  .reveal-up {
    opacity: 0;
    clip-path: inset(30% 0 0 0);
    animation: reveal-up linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 55%;
  }
}

@keyframes reveal-fade {
  to { opacity: 1; }
}
@keyframes reveal-up {
  to { opacity: 1; clip-path: inset(0 0 0 0); }
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--color-divider);
}
/* Blur lives on a pseudo-element, not on .site-header itself, so that
   backdrop-filter never creates a containing block for the fixed-position
   mobile nav panel nested inside this header (a well-known CSS gotcha:
   backdrop-filter/filter/transform on an ancestor traps position:fixed
   descendants to that ancestor's box instead of the viewport). */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  gap: var(--space-6);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  color: var(--color-text);
  flex-shrink: 0;
}

.brand svg { width: 22px; height: 22px; color: var(--color-text); }

.brand:hover { color: var(--color-primary-hover); }

.main-nav {
  display: flex;
  align-items: center;
  gap: clamp(var(--space-4), 3vw, var(--space-10));
}

.main-nav a {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding-block: var(--space-2);
  border-bottom: 1px solid transparent;
  white-space: nowrap;
}
.main-nav a:hover,
.main-nav a[aria-current='page'] {
  color: var(--color-text);
  border-bottom-color: var(--color-text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.theme-toggle:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.theme-toggle svg { width: 16px; height: 16px; }

.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  align-items: center;
  justify-content: center;
}
.nav-toggle svg { width: 18px; height: 18px; }

@media (max-width: 760px) {
  .main-nav {
    position: fixed;
    inset: 76px 0 0 0;
    background: var(--color-bg);
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: var(--space-8) clamp(var(--space-5), 5vw, var(--space-16));
    gap: var(--space-6);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
    border-top: 1px solid var(--color-divider);
  }
  .main-nav.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .main-nav a { font-size: var(--text-sm); }
  .nav-toggle { display: inline-flex; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--color-text);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  min-height: 44px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn--ghost {
  border-color: var(--color-border);
  color: var(--color-text-muted);
}
.btn--ghost:hover { color: var(--color-text); border-color: var(--color-border-strong); }

.btn--danger {
  border-color: var(--color-error);
  color: var(--color-error);
}
.btn--danger:hover { background: var(--color-error-highlight); }

.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  min-height: 32px;
}

.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: var(--space-8);
}

.card--flush { padding: 0; overflow: hidden; }

.divider {
  height: 1px;
  background: var(--color-divider);
  border: none;
  margin-block: var(--space-8);
}

.divider--vert {
  width: 1px;
  background: var(--color-divider);
}

/* ==========================================================================
   Tags / labels
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-3);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.field input,
.field select,
.field textarea {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  min-height: 44px;
  border-radius: var(--radius-sm);
}

.field textarea { min-height: 88px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-text);
  box-shadow: 0 0 0 1px var(--color-text);
}

.field input::placeholder { color: var(--color-text-faint); }

.form-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .form-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .form-grid--3 { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  border: 1px solid var(--color-border);
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  min-width: 640px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}

.data-table td.cell-wrap {
  white-space: normal;
  max-width: 220px;
}

.data-table th {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}

.data-table tbody tr:hover {
  background: var(--color-surface-offset);
}

.data-table tfoot td {
  font-weight: 700;
  border-top: 1px solid var(--color-border-strong);
  border-bottom: none;
  background: var(--color-surface-2);
}

.table-empty {
  padding: var(--space-12);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--color-divider);
  padding-block: var(--space-12);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.site-footer p, .site-footer a {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.site-footer a:hover { color: var(--color-text); }

/* ==========================================================================
   Misc utilities
   ========================================================================== */

.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.mt-0 { margin-top: 0; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4);
  z-index: 200;
}
.skip-link:focus { left: var(--space-4); top: var(--space-4); }

/* ==========================================================================
   Time is Money: meter box, modal, receipt, money-gif toast
   ========================================================================== */

.meter-box {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: clamp(var(--space-8), 4vw, var(--space-12));
  transition: background 320ms var(--ease-in-out), border-color 320ms var(--ease-in-out), box-shadow 320ms var(--ease-in-out);
}

.meter-box {
  position: relative;
}

.meter-box.is-overtime {
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
  box-shadow: 0 0 0 1px var(--color-error-border), var(--shadow-lg);
}

/* Pulse lives on a pseudo-element so it never overwrites the `animation`
   shorthand set by .reveal-up (which would reset the scroll-reveal state). */
.meter-box.is-overtime::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation: pulse-danger 2.4s var(--ease-in-out) infinite;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 0 1px var(--color-error-border); }
  50% { box-shadow: 0 0 0 1px var(--color-error); }
}

.meter-row {
  display: grid;
  gap: var(--space-8);
  grid-template-columns: 1fr;
}
@media (min-width: 760px) {
  .meter-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .meter-row.has-overtime { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.meter-row.has-overtime .meter__value {
  font-size: clamp(1.25rem, 0.7rem + 1.6vw, 2.25rem);
}

.meter {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.meter__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.meter-box.is-overtime .meter__label { color: #ffb3b3; }
.meter__value {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 1rem + 2vw, 2.75rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.meter__value--danger { color: var(--color-error); }
.meter__sub { font-size: var(--text-xs); color: var(--color-text-faint); }

.meter-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.meter-status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-text-faint);
}
.meter-status.is-live .meter-status__dot { background: var(--color-success); animation: blink 1.4s ease-in-out infinite; }
.meter-status.is-over .meter-status__dot { background: var(--color-error); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.25; } }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: var(--space-6);
  opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease-out);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  max-width: 440px; width: 100%; padding: var(--space-8);
  transform: scale(0.96) translateY(8px); transition: transform 260ms var(--ease-out);
}
.modal-overlay.is-open .modal { transform: scale(1) translateY(0); }

/* Receipt */
.receipt {
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  padding: var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.receipt-row { display: flex; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-2); border-bottom: 1px dashed var(--color-divider); }
.receipt-row:last-child { border-bottom: none; }

/* Money gif toast */
.money-toast {
  position: fixed; bottom: var(--space-6); right: var(--space-6);
  z-index: 250; width: min(240px, 60vw);
  border: 1px solid var(--color-error-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px);
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
  pointer-events: none;
}
.money-toast.is-visible { opacity: 1; transform: translateY(0); }
.money-toast img { width: 100%; display: block; }
.money-toast p { font-size: var(--text-xs); padding: var(--space-3); color: var(--color-error); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }

.participant-row-actions { display: flex; gap: var(--space-2); }

.badge-live {
  display: inline-block; padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--color-success); color: var(--color-success);
}
