/* LogicLab site — base.v1.css
 *
 * Shared by every page of playlogiclab.fr: Nocturnal tokens, fonts, reset, header, footer,
 * buttons, glass cards, legal template, focus, global pause and reduced motion.
 * The home pages (/ and /en) add home.v1.css on top.
 *
 * Tokens are copied from lib/core/theme/nocturnal.dart (Night.*) and the app home
 * (game halos). The site is dark only, like the app, the store icon and the share card.
 *
 * ⚠️ /assets/** is served "immutable" for one year (firebase.json). Once deployed, this
 * file never changes: copy it to base.v2.css and update every <link> instead.
 */

/* ---------- Fonts (self-hosted, SIL OFL 1.1, licences next to the files) ---------- */
@font-face {
  font-family: "Sora";
  src: url("/assets/fonts/sora-latin-var.v1.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("/assets/fonts/space-mono-400.v1.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Mono";
  src: url("/assets/fonts/space-mono-700.v1.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
/* Game faces, fetched only when a game preview uses them (Trace, Orbit, SONAR, Quantix, Pipe Lab…). */
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-sub.v1.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Orbitron";
  src: url("/assets/fonts/orbitron-var.v1.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched fallbacks: the swap to Sora / Space Mono does not move the layout. */
@font-face {
  font-family: "Sora Fallback";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Roboto");
  font-weight: 400 599;
  size-adjust: 112.8%;
  ascent-override: 86%;
  descent-override: 25.7%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Sora Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Roboto Bold");
  font-weight: 600 900;
  size-adjust: 107.2%;
  ascent-override: 90.5%;
  descent-override: 27%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Space Mono Fallback";
  src: local("Courier New"), local("CourierNewPSMT"), local("Liberation Mono");
  size-adjust: 102%;
  ascent-override: 109.8%;
  descent-override: 35.4%;
  line-gap-override: 0%;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  /* Nocturnal — lib/core/theme/nocturnal.dart */
  --ink: #0B0F1A;              /* Night.bg: every page, theme-color */
  --surface: #1B2233;          /* surfaceContainerHighest: game window, mobile bar */
  --surface-2: #141A28;
  --glass-top: rgba(255, 255, 255, .08);    /* Night.cardTop */
  --glass-bottom: rgba(255, 255, 255, .04); /* Night.cardBottom */
  --hairline: rgba(255, 255, 255, .12);     /* Night.stroke */
  --outline: rgba(255, 255, 255, .20);      /* outlineVariant */
  --text-hi: #F3F5FB;          /* Night.textHi */
  --text-lo: #9AA3B8;          /* Night.textLo — 7.3:1 on ink */
  --teal: #1FB8AD;             /* UI accent: links, CTA, focus. Never means "solved". */
  --teal-hi: #3CCFC3;          /* hover of teal surfaces */
  --on-teal: #03201D;          /* text on teal (onPrimary) */
  --solved: #2BD4C4;           /* only what is done or reached */
  --violet: #7A6CF0;
  --flask: #00C0F0;            /* brand halo only */
  --error: #FF6B6B;
  --streak: #FF9D4D;
  --streak-bg: #2A1608;
  --mint: #8FE9E2;             /* "NIV. N" */
  --quest: #FFC24B;

  /* Game halos — app home tiles (kAllGameCodes order) */
  --g-tango: #E9C45A;
  --g-queens: #E07A6B;
  --g-lexilab: #E96A86;
  --g-pulse: #3FD0CE;
  --g-sudoku: #8C7BF0;
  --g-cipher: #E7B84A;
  --g-mate: #9B6CF0;
  --g-memory: #B07BE8;
  --g-math: #3DF5C4;
  --g-mines: #40E0FF;
  --g-zip: #FF8A4C;
  --g-orbit: #E15BEA;
  --g-pipe: #8BE04A;
  --g-atoll: #1BA9BE;
  --g-tessella: #9B6CF0;

  /* Type */
  --font-display: "Sora", "Sora Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Space Mono", "Space Mono Fallback", ui-monospace, "SF Mono", Menlo, monospace;

  /* Motion — the app's Flutter curves and durations */
  --e-settle: cubic-bezier(.215, .61, .355, 1);   /* Curves.easeOutCubic: everything that lands */
  --e-fade: cubic-bezier(0, 0, .58, 1);           /* Curves.easeOut: fades, presses, link colour */
  --e-pop: cubic-bezier(.175, .885, .32, 1.275);  /* Curves.easeOutBack: only what pops in */
  --e-exit: cubic-bezier(.42, 0, 1, 1);           /* Curves.easeIn: exits only */
  --e-glide: cubic-bezier(.42, 0, .58, 1);        /* Curves.easeInOut: sheen, programmed scrolls */
  --e-fall: cubic-bezier(.55, .055, .675, .19);   /* Curves.easeInCubic: top half of a flap */
  --stagger: 26ms;
  --stagger-base: 60ms;
  --d-press: 120ms;
  --d-flap: 150ms;
  --d-out: 260ms;
  --d-in: 380ms;
  --d-reveal: 520ms;
  --d-sheen: 600ms;
  --d-splash: 720ms;
  --d-aurora: 900ms;
  --d-hold: 1200ms;
  --d-level: 1400ms;
  --d-ring: 1500ms;
  --d-ring-atoll: 1700ms;
  --d-intro: 2200ms;

  /* Layout */
  --gutter: clamp(16px, 4vw, 32px);
  --maxw: 1180px;
  --bar-h: 64px;
  --r-tile: 16px;
  --r-card: 20px;
  --r-dialog: 24px;
  --shadow-lift: 0 24px 48px -24px rgba(0, 0, 0, .7);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scrollbar-gutter: stable; /* the page does not shift when the sample window locks the scroll */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + 12px);
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text-hi);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
@supports (overflow: clip) { body { overflow-x: clip; } }
h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: .18em; transition: color var(--d-press) var(--e-fade); }
a:hover { color: var(--teal-hi); }
::selection { background: rgba(31, 184, 173, .35); color: var(--text-hi); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
strong, b { font-weight: 700; color: var(--text-hi); }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text-hi); font-weight: 700; text-wrap: balance; }
h1 { font-weight: 800; font-size: clamp(2.3rem, 1.25rem + 4.2vw, 4.4rem); line-height: 1.04; letter-spacing: -.04em; }
h2 { font-size: clamp(1.75rem, 1.1rem + 2.3vw, 2.75rem); line-height: 1.1; letter-spacing: -.03em; }
h3 { font-size: 1.125rem; line-height: 1.3; letter-spacing: -.01em; }
p { text-wrap: pretty; }
.lead { font-size: clamp(1.05rem, .98rem + .35vw, 1.25rem); line-height: 1.55; color: var(--text-lo); }
.muted { color: var(--text-lo); }
.eyebrow {
  display: inline-block;
  font: 700 .75rem/1.3 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-lo);
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: calc(var(--maxw) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(64px, 9vw, 120px); position: relative; }
.section-head { display: grid; gap: 14px; max-width: 46rem; margin-bottom: clamp(28px, 4vw, 48px); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Skip link: first focusable element of every page */
.skip-link {
  position: absolute; left: 12px; top: -64px; z-index: 100;
  padding: 10px 16px; border-radius: 12px;
  background: var(--teal); color: var(--on-teal); font: 700 .95rem/1 var(--font-display); text-decoration: none;
  transition: top var(--d-in) var(--e-settle);
}
.skip-link:focus, .skip-link:focus-visible { top: 12px; color: var(--on-teal); }

/* ---------- Site bar ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 15, 26, .88);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d-out) var(--e-fade), background-color var(--d-out) var(--e-fade);
}
.site-header.is-scrolled { border-bottom-color: var(--hairline); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .site-header { background: rgba(11, 15, 26, .72); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); }
}
.bar { display: flex; align-items: center; gap: 12px; height: var(--bar-h); }
.brand {
  display: inline-flex; align-items: center; gap: 10px; flex: none;
  color: var(--text-hi); text-decoration: none;
  font: 700 1.125rem/1 var(--font-display); letter-spacing: -.02em;
  min-height: 44px; border-radius: 12px;
}
.brand:hover { color: var(--text-hi); }
.brand__icon { position: relative; width: 34px; height: 34px; flex: none; }
.brand__icon img { width: 34px; height: 34px; border-radius: 9px; }
.brand__icon::before { /* static flask halo #00C0F0 at 18 % */
  content: ""; position: absolute; inset: -10px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(0, 192, 240, .18), rgba(0, 192, 240, 0));
}
.site-nav { display: none; gap: 4px; margin-left: 20px; }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--text-lo); text-decoration: none; font: 600 .95rem/1 var(--font-body);
}
.site-nav a:hover { color: var(--text-hi); }
@media (min-width: 860px) { .site-nav { display: flex; } }
.bar__tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.lang {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 44px; min-height: 44px; padding: 0 10px; border-radius: 12px;
  font: 700 .8rem/1 var(--font-mono); letter-spacing: .08em; text-decoration: none; color: var(--text-lo);
}
.lang:hover { color: var(--text-hi); background: rgba(255, 255, 255, .06); }
.lang [aria-current] { color: var(--text-hi); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--hairline); background: rgba(255, 255, 255, .04); color: var(--text-hi);
  font: 600 .875rem/1 var(--font-body);
  transition: background-color var(--d-press) var(--e-fade), border-color var(--d-press) var(--e-fade);
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); border-color: var(--outline); }
.icon-btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn__label { display: none; }
@media (min-width: 600px) { .icon-btn__label { display: inline; } }
/* Pause toggle: shows "pause" while motion plays, "play" once paused */
.pause-btn .i-play { display: none; }
.pause-btn[aria-pressed="true"] { border-color: rgba(31, 184, 173, .55); background: rgba(31, 184, 173, .12); }
.pause-btn[aria-pressed="true"] .i-play { display: block; }
.pause-btn[aria-pressed="true"] .i-pause { display: none; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 24px; border-radius: 16px; border: 1px solid transparent;
  font: 700 1rem/1.1 var(--font-display); letter-spacing: -.01em; text-decoration: none; text-align: center;
  transition: transform var(--d-press) var(--e-fade), background-color var(--d-press) var(--e-fade), border-color var(--d-press) var(--e-fade), color var(--d-press) var(--e-fade);
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn--primary { background: var(--teal); color: var(--on-teal); box-shadow: 0 10px 30px -12px rgba(31, 184, 173, .55); }
.btn--primary:hover { background: var(--teal-hi); color: var(--on-teal); }
.btn--ghost { background: rgba(255, 255, 255, .04); border-color: var(--hairline); color: var(--text-hi); }
.btn--ghost:hover { background: rgba(255, 255, 255, .08); border-color: var(--outline); color: var(--text-hi); }
.btn--small { min-height: 44px; padding: 0 16px; border-radius: 12px; font-size: .925rem; }

/* ---------- Surfaces ---------- */
.glass {
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom));
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 26px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--hairline); background: rgba(255, 255, 255, .05);
  font: 700 .6875rem/1.2 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-lo);
}
.tag-example { /* "Exemple" / "Échantillon": nothing on the site pretends to be live */
  display: inline-flex; align-items: center; min-height: 22px; padding: 3px 8px; border-radius: 6px;
  background: rgba(255, 255, 255, .07); color: var(--text-lo);
  font: 700 .6875rem/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
}

/* Official store badges (artwork unmodified, height-scaled only) */
.store-badges { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.store-badge { display: inline-flex; border-radius: 10px; line-height: 0; }
.store-badge img { height: 48px; width: auto; }
.store-badge:focus-visible { outline-offset: 3px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  padding-block: 40px calc(40px + env(safe-area-inset-bottom));
  color: var(--text-lo); font-size: .9375rem;
}
.footer-grid { display: grid; gap: 28px; }
@media (min-width: 860px) { .footer-grid { grid-template-columns: 1.2fr 2fr 1fr; align-items: start; } }
.footer-brand { display: flex; align-items: center; gap: 12px; color: var(--text-hi); }
.footer-brand img { width: 40px; height: 40px; border-radius: 10px; }
.footer-brand b { display: block; font: 700 1.05rem/1.2 var(--font-display); }
.footer-brand small { display: block; color: var(--text-lo); font-size: .85rem; }
.footer-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 20px; padding: 0; margin: 0; list-style: none; }
.footer-links a, .footer-meta a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-lo); text-decoration: none; }
.footer-links a:hover, .footer-meta a:hover { color: var(--text-hi); }
.footer-meta { display: grid; gap: 0; justify-items: start; }
.footer-copy { grid-column: 1 / -1; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .85rem; }

/* ---------- Secondary pages (legal, support, bridges, 404) ---------- */
.page-glow { position: relative; isolation: isolate; }
.page-glow::before { /* the app's static aurora: teal top-left, violet bottom-right */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 560px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 70% at 8% 0%, rgba(31, 184, 173, .16), rgba(31, 184, 173, 0) 70%),
    radial-gradient(50% 60% at 100% 10%, rgba(122, 108, 240, .14), rgba(122, 108, 240, 0) 70%);
}
.legal { max-width: 760px; margin-inline: auto; padding: clamp(28px, 6vw, 64px) var(--gutter) clamp(56px, 8vw, 96px); }
.legal-back {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 20px;
  color: var(--text-lo); text-decoration: none; font-weight: 600;
}
.legal-back:hover { color: var(--text-hi); }
.legal h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); margin-bottom: 10px; }
.legal-date { font: 400 .8125rem/1.5 var(--font-mono); letter-spacing: .04em; color: var(--text-lo); margin-bottom: 32px; }
.legal h2 { font-size: clamp(1.25rem, 1.1rem + .6vw, 1.5rem); margin: 40px 0 12px; letter-spacing: -.02em; }
.legal h3 { margin: 24px 0 8px; }
.legal p, .legal li { color: #C9D0DE; }
.legal p + p { margin-top: 12px; }
.legal ul, .legal ol { padding-left: 1.25rem; margin: 12px 0; display: grid; gap: 8px; }
.legal li::marker { color: var(--teal); }
.legal a { overflow-wrap: anywhere; }
.legal em { color: var(--text-hi); }
.legal .cta-box, .legal .support-contact, .legal .notice {
  margin: 24px 0; padding: 20px 22px; border-radius: var(--r-card);
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom)); border: 1px solid var(--hairline);
}
.legal .step { display: flex; gap: 16px; align-items: flex-start; margin: 16px 0; }
.legal .step-num {
  flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: rgba(31, 184, 173, .14); color: var(--teal); font: 700 .9rem/1 var(--font-mono);
}
.legal .step-content { flex: 1; min-width: 0; }
.legal .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 14px; background: var(--teal); color: var(--on-teal); font: 700 .95rem/1.1 var(--font-display); text-decoration: none;
}
.legal .btn-primary:hover { background: var(--teal-hi); color: var(--on-teal); }

/* Centered card used by /signin, /confirm-delete, /telecharger and the 404 */
/* The bar is --bar-h plus its 1 px bottom border: without the -1px every card page scrolls by a pixel. */
.card-page { min-height: calc(100vh - var(--bar-h) - 1px); display: grid; place-items: center; padding: 32px var(--gutter) 64px; }
@supports (min-height: 100svh) { .card-page { min-height: calc(100svh - var(--bar-h) - 1px); } }
.center-card {
  width: 100%; max-width: 460px; padding: 32px 28px; text-align: center;
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom)); border: 1px solid var(--hairline);
  border-radius: var(--r-dialog); box-shadow: var(--shadow-lift);
}
.center-card .flask { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 18px; }
.center-card h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); margin-bottom: 10px; }
.center-card p { color: var(--text-lo); }
.center-card .store-badges { justify-content: center; margin-top: 20px; }

/* ---------- Motion: global pause and reduced motion ---------- */
/* The bar's Pause button sets html.is-paused: CSS animations freeze; site.v1.js pauses WAAPI and canvases. */
html.is-paused *, html.is-paused *::before, html.is-paused *::after { animation-play-state: paused !important; }
/* …except a sample the visitor explicitly chose to play ([data-optin] on its stage). */
html.is-paused [data-optin], html.is-paused [data-optin] *, html.is-paused [data-optin] *::before, html.is-paused [data-optin] *::after { animation-play-state: running !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  /* Composed and still. A container the visitor explicitly starts ([data-optin]) may still play. */
  *:not([data-optin], [data-optin] *),
  *:not([data-optin], [data-optin] *)::before,
  *:not([data-optin], [data-optin] *)::after { animation: none !important; transition: none !important; }
}
