/* Reset & base element styling */

/* Self-hosted (assets/fonts/) rather than linked from Google Fonts: the
   app's CSP is font-src 'self', and pulling from fonts.gstatic.com would
   mean loosening that policy. Variable font, so one file per subset covers
   the whole 200-800 weight range we use. */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/assets/fonts/plus-jakarta-sans-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/assets/fonts/plus-jakarta-sans-latin-ext.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

/* Chromium's same-origin MPA view transitions — a soft cross-fade between
   full page loads instead of a hard cut. Unsupported browsers (Firefox,
   Safari at time of writing) ignore the unknown at-rule entirely, so this
   needs no fallback or feature query. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
  overflow-x: clip;
}

body {
  overflow-x: clip;
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
}

/* ---------- Ambient background ----------
   Soft, slow-drifting colour underneath everything, so the glass chrome
   (header/nav/modals/hero panels) has something to actually refract. Built
   from the existing accent/status hues via color-mix — no new colours. */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -2;
  background:
    radial-gradient(640px circle at 12% 18%, color-mix(in srgb, var(--color-accent) 30%, transparent), transparent 62%),
    radial-gradient(560px circle at 88% 12%, color-mix(in srgb, var(--status-maybe) 22%, transparent), transparent 60%),
    radial-gradient(720px circle at 78% 85%, color-mix(in srgb, var(--color-info) 22%, transparent), transparent 62%),
    radial-gradient(520px circle at 20% 90%, color-mix(in srgb, var(--status-available) 16%, transparent), transparent 60%);
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
  animation: ambient-drift 46s ease-in-out infinite alternate,
             ambient-breathe 10s ease-in-out infinite;
}

@keyframes ambient-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2%, 2%, 0) scale(1.06); }
}

/* Slow glow "breathing" independent of the drift — the ambient colour
   fields brighten and dim a touch so the glass chrome above never sits on a
   perfectly static backdrop. */
@keyframes ambient-breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.68; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

/* Fine grain over the ambient gradient so large blurred colour fields don't
   read as flat banded blobs — imperceptible individually, adds texture. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  mix-blend-mode: overlay;
  pointer-events: none;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p {
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

a {
  color: var(--color-accent-text);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

small {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: 1rem;
}

fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

/* ---------- Focus visibility ---------- */
:focus {
  outline: none;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: 2px solid transparent;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Scrollbars (progressive, non-blocking) ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

/* WebKit/Blink-only refinement layered on top of the standard properties
   above (Firefox already gets a perfectly fine thin scrollbar from those) —
   a hover glow so a dragged thumb feels like part of the same glass system. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-accent);
  box-shadow: var(--glow-accent-sm);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--color-accent-subtle);
  color: var(--color-accent-active);
}

/* ---------- Utility: visually hidden but accessible ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -48px;
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 1000;
  transition: top var(--duration-base) var(--ease-standard);
}

.skip-link:focus {
  top: var(--space-3);
}

/* ---------- Flash message stack ----------
   Rendered by includes/flash-messages.php at the top of every page's
   <main>. Previously had no styling of its own at all, so two queued
   messages sat flush against each other and the stack ran straight into
   the page heading below it. */
.flash-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.flash-stack .alert {
  animation: flash-in var(--duration-slow) var(--ease-spring) both;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Scroll progress ----------
   A thin accent line across the top of the viewport that fills as the page
   scrolls. Pure CSS via a scroll-driven animation — no JS, no scroll
   listener. Browsers without animation-timeline support simply never show
   it (the @supports guard keeps it at zero width there). */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .app-shell::before,
    .auth-shell::before {
      content: "";
      position: fixed;
      top: 0;
      left: 0;
      height: 2px;
      width: 100%;
      transform-origin: 0 50%;
      z-index: calc(var(--z-header) + 1);
      background: var(--gradient-accent-solid);
      box-shadow: var(--glow-accent-sm);
      pointer-events: none;
      animation: scroll-progress linear both;
      animation-timeline: scroll(root block);
    }
  }
}

@keyframes scroll-progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Generic utilities ---------- */
.visually-hide { display: none !important; }

.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-center { text-align: center; }

/* Size counterparts to the colour utilities above. Added because several
   templates reached for style="font-size:var(--text-sm)" instead, and the
   app's own CSP (style-src 'self', no 'unsafe-inline') drops inline style
   attributes — so those rows have been rendering at full body size. A class
   is the only form of this that actually survives to the browser. */
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--space-4); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
