/* ============================================================
   CoolCourts: refined athletic-club / scoreboard aesthetic
   Fraunces (display) · Hanken Grotesk (UI) · Spline Sans Mono (figures)
   ============================================================ */

:root {
  /* Experimental: dark theme retinted to cooliotto.com's code-editor palette
     (near-black canvas, wire blue, comment gray). Signal orange was tried
     first but sat too close to the booked-slot red; wire blue keeps the two
     states visually distinct. Revert to the original scoreboard greens/
     chartreuse below if this doesn't land. */
  --ink:      #0b0e14;
  --court:    #11151c;
  --raised:   #171c25;
  --raised-2: #1e2430;
  --line:     rgba(243, 239, 228, 0.10);
  --line-2:   rgba(243, 239, 228, 0.18);
  /* Opaque equivalent of --line composited over --raised, for the floating grid
     header: a translucent border would show the scrolling rows through it. Built
     from theme vars so it adapts to light/dark without a second declaration. */
  --line-solid: color-mix(in srgb, var(--cream) 10%, var(--raised));
  --cream:    #f3efe4;
  --muted:    #97a39d;
  --faint:    #5b6472;   /* cooliotto.com "comment gray" */
  --ball:     #7c9cf4;   /* cooliotto.com "wire blue" */
  --ball-dim: #6b86d2;
  --red:      #e2503f;   /* service-line red */

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;

  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85);

  --display: "Fraunces", Georgia, serif;
  --ui:      "Hanken Grotesk", system-ui, sans-serif;
  --mono:    "Spline Sans Mono", ui-monospace, monospace;
}

/* Light theme: derived from the same cooliotto.com retint as the dark theme
   above -- neutral surfaces instead of green-tinted, and a deepened "wire
   blue" (the pastel dark-theme value is too light to read on white). */
[data-theme="light"] {
  --ink:      #f5f6f7;
  --court:    #ffffff;
  --raised:   #eef0f2;
  --raised-2: #e2e5e9;
  --line:     rgba(15, 17, 20, 0.12);
  --line-2:   rgba(15, 17, 20, 0.20);
  --cream:    #16201a;
  --muted:    #515b54;
  --faint:    #6b7280;
  --ball:     #3a56c4;
  --ball-dim: #2c4399;
  --red:      #cf3b2b;
  --shadow:   0 24px 60px -30px rgba(20, 40, 30, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Only html is pinned to viewport height. Body must be free to grow to content
   height; capping it at 100% shrinks the sticky topbar's containing block to one
   screen, so the bar un-sticks once you scroll past the first viewport. */
html { height: 100%; }

body {
  font-family: var(--ui);
  background: var(--ink);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  position: relative;
  /* clip (not hidden): still prevents sideways page scroll, but unlike hidden it
     doesn't make <body> a scroll container, which would break the sticky topbar. */
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  transition: background-color 0.2s, color 0.2s;
}

/* Atmospheric backdrop: a faint squash-court outline + warm glow. */
.court-lines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 85% -10%, color-mix(in srgb, var(--ball) 8%, transparent), transparent 55%),
    radial-gradient(90% 70% at 0% 110%, rgba(226, 80, 63, 0.06), transparent 55%);
}
.court-lines::before {
  content: "";
  position: absolute;
  inset: clamp(48px, 7vw, 80px);
  border: 1.5px solid var(--line);
  border-radius: 4px;
}
.court-lines::after {
  /* the "service line": a single red horizontal stroke */
  content: "";
  position: absolute;
  left: clamp(48px, 7vw, 80px);
  right: clamp(48px, 7vw, 80px);
  top: 58%;
  border-top: 1.5px solid rgba(226, 80, 63, 0.16);
}

main, .topbar { position: relative; z-index: 1; }
main { flex: 1 0 auto; }

/* -- Top bar -------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40; /* above page content and the grid's own sticky header */
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  /* Opaque: the bar is sticky, so a translucent/frosted background would show the
     rows scrolling behind it (which reads as bleed-through above the pinned grid
     header). Solid --ink looks the same at rest, with nothing showing through. */
  background: var(--ink);
  height: 56px;
}
/* .topbar's display:flex would otherwise override the UA [hidden] rule, so the
   bar never actually hides on logout. This makes the hidden attribute win. */
.topbar[hidden] { display: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--cream);
  padding: 0.5rem 0;
  flex-shrink: 0;
}
.brand-ball {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--ball);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ball) 14%, transparent), 0 0 18px color-mix(in srgb, var(--ball) 50%, transparent);
}
.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

/* Page-navigation links -- desktop: right of brand; mobile: full-width scrollable second row. */
.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1; /* fill space between brand and nav-actions */
}

/* Utility controls (time toggle, theme, logout, email) -- always on the same row as the brand. */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--line);
  margin-left: auto;
  flex-shrink: 0;
}

/* Shared button/link styling for both nav regions */
.nav a, .nav button, .nav-actions a, .nav-actions button {
  font-family: var(--ui);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  transition: color 0.18s, background 0.18s;
}
.nav a:hover, .nav button:hover,
.nav-actions a:hover, .nav-actions button:hover { color: var(--cream); background: var(--raised); }
.nav a.active { color: var(--ink); background: var(--ball); }
.who {
  color: var(--faint);
  font-size: 0.82rem;
  padding: 0 0.5rem;
}

/* Theme toggle (sun/moon). Placed after .nav rules so it wins the specificity
   tie with `.nav button` on padding/size. */
button.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
button.theme-toggle:hover { color: var(--cream); background: var(--raised); }
.theme-toggle-corner { position: absolute; top: 0.8rem; right: 0.8rem; }
.nav-icon { width: 18px; height: 18px; display: block; }

/* 12h / 24h time-format toggle (text). After .nav rules to win the specificity tie. */
button.time-toggle {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.55rem;
  min-width: 3em;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
button.time-toggle:hover { color: var(--cream); background: var(--raised); }

/* Footer credit, on every page except the auth page (which has its own
   Cooliotto credit inside the card -- see .auth-built-by). */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 1.6rem 1rem 2.2rem;
}
/* .app-footer's display:flex would otherwise override the UA [hidden] rule,
   the same issue .topbar works around above. */
.app-footer[hidden] { display: none; }
.app-footer img { height: 20px; width: auto; opacity: 0.65; transition: opacity 0.2s; }
.app-footer a:hover img { opacity: 1; }
[data-theme="dark"] .app-footer img { filter: invert(1) brightness(1.15); }
.footer-credit { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--faint); }
.footer-brand { display: inline-flex; align-items: center; gap: 0.32rem; font-family: var(--display); font-weight: 600; font-size: 0.95rem; color: var(--cream); }
.footer-brand .brand-ball { width: 8px; height: 8px; box-shadow: none; }
.footer-dot { color: var(--faint); }
.footer-cooliotto { display: inline-flex; align-items: center; }

/* Whitelabel brand chrome */
.brand-logo { height: 34px; width: auto; max-width: 170px; object-fit: contain; display: block; }
.brand-icon { height: 32px; width: 32px; max-width: 32px; } /* square topbar avatar */
.auth-club { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; text-align: center; }
.auth-club-logo { max-width: 230px; max-height: 96px; width: auto; height: auto; }
.auth-club-name { font-family: var(--display); font-weight: 600; font-size: 1.9rem; letter-spacing: -0.02em; }
.powered-by { font-size: 0.78rem; color: var(--faint); letter-spacing: 0.02em; }
/* Shared "CoolCourts <Product>" wordmark convention: suite name (CoolCourts) in the
   display font with no color override, product name (Booking / Ladder) in
   --ball to set it apart, tagline on its own smaller line. Reused by the
   whitelabel "powered by" credit and the in-app "Runs on" footer credit. */
.brand-word-coolcourts { font-family: var(--display); font-weight: 600; }
.brand-word-product { font-family: var(--display); font-weight: 600; color: var(--ball); }
.brand-word-tagline { display: block; margin-top: 0.15rem; font-size: 0.85em; color: var(--faint); }

/* -- Layout helpers ------------------------------------------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 4vw, 3rem); }
/* The booking page (esp. the week grid) needs more room than reading-width pages. */
.wrap-wide { max-width: min(1640px, 96vw); }
.page-head { margin-bottom: 1.8rem; animation: rise 0.6s both; }
.eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.7rem;
  color: var(--ball-dim);
  margin-bottom: 0.7rem;
}
h1.title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
}
h1.title em { font-style: italic; color: var(--ball); }
.sub { color: var(--muted); margin-top: 0.6rem; max-width: 46ch; }

/* -- Controls --------------------------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: flex-end;
  padding: 1rem 1.1rem;
  background: var(--court);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 1.6rem;
  animation: rise 0.6s 0.05s both;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--faint);
}
input, select {
  font-family: var(--ui);
  font-size: 0.95rem;
  color: var(--cream);
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.8rem;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
input:focus, select:focus { border-color: var(--ball); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ball) 16%, transparent); }
.seg { display: inline-flex; background: var(--raised); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 3px; }
.seg button {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  background: none; border: 0; cursor: pointer;
  padding: 0.4rem 0.8rem; border-radius: 6px;
  transition: all 0.15s;
}
.seg button.on { background: var(--ball); color: var(--ink); font-weight: 600; }

/* -- Buttons ---------------------------------------------------- */
.btn {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 0;
  border-radius: var(--r-sm);
  padding: 0.72rem 1.2rem;
  transition: transform 0.12s, filter 0.18s, background 0.18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ball); color: var(--ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--raised); color: var(--cream); border: 1px solid var(--line-2); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--raised-2); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(226, 80, 63, 0.4); }
.btn-danger:hover { background: rgba(226, 80, 63, 0.12); }
.btn-block { width: 100%; }

/* -- Availability grid (the centrepiece) ------------------------ */
/* Horizontal scroll only (the wide week table); the page owns vertical scroll,
   so there's no nested vertical scrollbar. The header is floated on scroll via
   JS (applyHeader) using a transform rather than position:sticky, because this
   horizontal-overflow container would otherwise capture vertical sticking. */
.grid-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--court); animation: rise 0.6s 0.1s both; }
/* Fixed layout so column widths are defined by the colgroup, letting booked cells
   fill their column and ellipsize long names instead of widening the column. */
.slot-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.slot-grid col.col-time { width: 80px; }
/* Week grid: explicit per-column widths. min-width:100% makes the table fill the
   container when the columns don't add up to its width (so the header reaches the
   rounded right edge instead of stopping short); when there are enough courts to
   exceed the width, it grows past and the grid-scroll wrapper scrolls sideways. */
.slot-grid.week { width: auto; min-width: 100%; }
.slot-grid.week col.col-time-week { width: 64px; }
.slot-grid.week col.col-day { width: 104px; }
.slot-grid th, .slot-grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.slot-grid th:last-child, .slot-grid td:last-child { border-right: 0; }
.slot-grid tr:last-child td { border-bottom: 0; }
.slot-grid thead th {
  /* Floated on scroll: applyHeader sets --head-y so the whole header (both rows
     in the week view) slides down to stay pinned just below the top nav. */
  position: relative;
  z-index: 5;
  transform: translateY(var(--head-y, 0px));
  background: var(--raised);
  /* No cell borders on the header: with border-collapse the browser paints the
     translucent body-cell border at the seam (and a transform makes it worse), so
     rows bleed through. Draw the gridlines as an opaque inset box-shadow instead,
     since it paints with the cell, moves with the transform, and can't be overridden. */
  border: 0;
  box-shadow: inset -1px -1px 0 var(--line-solid);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  padding: 0.85rem 0.6rem;
  text-align: center;
  color: var(--cream);
}
.slot-grid thead th:first-child { text-align: left; padding-left: 1.1rem; }
.time-col {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
  padding: 0 0.5rem;
  background: rgba(0,0,0,0.12);
}
.slot-cell { padding: 0.4rem; text-align: center; }
.slot {
  display: block;
  box-sizing: border-box;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ball);
  background: color-mix(in srgb, var(--ball) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--ball) 22%, transparent);
  border-radius: 7px;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  white-space: nowrap; /* keep "12:00 PM" on one line in the dense week grid */
  transition: background 0.15s, transform 0.1s, color 0.15s;
}
button.slot:hover { background: var(--ball); color: var(--ink); transform: translateY(-1px); }
.slot-empty { color: var(--faint); font-family: var(--mono); font-size: 1rem; opacity: 0.5; }

/* Booked: red. Non-editable slots (.slot-booked alone) are non-interactive;
   editable slots (.slot-edit) are buttons with a hover highlight. */
.slot-booked {
  color: var(--red);
  background: rgba(226, 80, 63, 0.13);
  border-color: rgba(226, 80, 63, 0.45);
  cursor: not-allowed;
  opacity: 0.55;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
button.slot-edit {
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
button.slot-edit:hover {
  opacity: 1;
  background: rgba(226, 80, 63, 0.22);
  border-color: rgba(226, 80, 63, 0.7);
  color: var(--red);
  transform: none;
}
.slot-name {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-type-pill {
  width: 100%;
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 600;
  color: #1a1f1d;
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}
/* Past: greyed, non-bookable */
.slot-past {
  color: var(--faint);
  background: transparent;
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.55;
}

/* Week grid: two-row header (day labels over their courts). Both rows inherit
   the --head-y transform above, so they float together as one block. */
.day-head {
  font-family: var(--display);
  font-weight: 600;
  text-align: center;
}
.court-head {
  font-family: var(--ui);
  font-weight: 500;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  padding: 0.45rem 0.5rem;
}

/* Week navigation */
.week-nav { display: inline-flex; align-items: center; gap: 0.5rem; }
.week-nav .btn { padding: 0.45rem 0.75rem; font-size: 1.05rem; line-height: 1; }
.week-label { font-family: var(--mono); font-size: 0.85rem; color: var(--cream); min-width: 13ch; text-align: center; }

/* -- Cards / bookings list --------------------------------------- */
.cards { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
  background: var(--court);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: rise 0.5s both;
  position: relative;
  overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ball); }
.card .court-name { font-family: var(--display); font-weight: 600; font-size: 1.35rem; letter-spacing: -0.01em; }
.card .when { color: var(--muted); font-size: 0.92rem; }
.card .time { font-family: var(--mono); font-size: 1.1rem; color: var(--cream); }
.card .card-actions { margin-top: 0.4rem; }

/* -- Data table (members grid etc.) ----------------------------- */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 0.8rem;
  background: var(--ink);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--raised);
}
.data-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--cream);
  background: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--raised); }
.data-table tbody tr.row-off td { opacity: 0.45; }
.data-table .col-actions { white-space: nowrap; text-align: right; }

.btn-sm {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--r-sm);
}
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid currentColor;
}
.badge-active  { color: #6ec6ca; }
.badge-off     { color: var(--faint); }
.badge-admin   { color: var(--ball); }
.badge-member  { color: var(--muted); }

/* -- Admin: courts & hours --------------------------------------- */
.admin-section {
  margin-bottom: 2.4rem;
  animation: rise 0.5s both;
}
.section-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.sub-title {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
  margin: 1.4rem 0 0.7rem;
}
.court-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  background: var(--court);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 0.8rem;
}
.court-form .field { flex: 1; min-width: 140px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--cream);
  cursor: pointer;
  white-space: nowrap;
  padding-bottom: 0.6rem;
}
.check input { width: auto; }
/* Toggle switch -- replaces native checkboxes in forms/modals */
.toggle { display:inline-flex; align-items:center; gap:0.5rem; cursor:pointer; user-select:none; }
.toggle input[type="checkbox"] { position:absolute; opacity:0; width:0; height:0; pointer-events:none; }
.toggle-track { position:relative; width:34px; height:18px; background:var(--line-2); border-radius:9px; transition:background 0.18s; flex-shrink:0; }
.toggle input[type="checkbox"]:checked + .toggle-track { background:var(--ball); }
.toggle-track::after { content:''; position:absolute; top:2px; left:2px; width:14px; height:14px; background:#fff; border-radius:50%; transition:left 0.18s; }
.toggle input[type="checkbox"]:checked + .toggle-track::after { left:18px; }
.toggle input[type="checkbox"]:disabled + .toggle-track { opacity:0.4; cursor:not-allowed; }
.toggle-label { font-size:0.9rem; color:var(--cream); }

.swatch-picker { display: flex; gap: 0.4rem; align-items: center; }
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.selected { border-color: var(--cream); }
.hours-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.hours-row .toggle { min-width: 9rem; }
.hours-row .dash { color: var(--faint); }
#hoursEditor { margin-bottom: 1.2rem; }

/* -- Auth backdrop ------------------------------------------------ */
/* Fixed behind the login card; toggled via .hidden in renderAuth/renderChrome.
   z-index 0 puts it below main's z-index 1 (see "main, .topbar" above), same
   trick used for .court-lines. */
#authBackdrop { position: fixed; inset: 0; z-index: 0; isolation: isolate; }
.login-bg-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.login-bg-overlay { position: absolute; inset: 0; background: rgba(11, 14, 20, 0.6); z-index: 1; }

/* -- Auth screen ------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  position: relative;
  width: 100%; max-width: 410px;
  background: var(--court);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(1.6rem, 4vw, 2.6rem);
  box-shadow: var(--shadow);
  animation: rise 0.6s both;
}
.auth-brand-block { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; text-align: center; }
.auth-brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand-tagline {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: lowercase;
  letter-spacing: 0.16em;
  color: var(--faint);
  margin-bottom: 1.6rem;
}
.auth-built-by {
  display: flex;
  justify-content: center;
  padding-top: 1.2rem;
  margin-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.auth-built-by img { height: 20px; width: auto; opacity: 0.65; transition: opacity 0.2s; }
.auth-built-by a:hover img { opacity: 1; }
[data-theme="dark"] .auth-built-by img { filter: invert(1) brightness(1.15); }
.auth h1 { font-family: var(--display); font-weight: 600; font-size: 2rem; letter-spacing: -0.02em; line-height: 1.05; }
.auth h1 em { font-style: italic; color: var(--ball); }
.auth p.lead { color: var(--muted); margin: 0.5rem 0 1.6rem; }
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form .row { display: flex; gap: 0.7rem; }
.form .row .field { flex: 1; }
.form .field { display: flex; flex-direction: column; gap: 0.35rem; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--faint);
  font-size: 0.8rem;
  margin-top: 1.2rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.btn-ladder { display: flex; align-items: center; justify-content: center; gap: 0.55rem; margin-top: 0.9rem; }
.btn-ladder .brand-ball { box-shadow: none; }
.auth-registration-note { margin-top: 1.2rem; font-size: 0.8125rem; color: var(--muted); text-align: center; }
.form-error {
  font-size: 0.88rem;
  color: var(--red);
  background: rgba(226, 80, 63, 0.1);
  border: 1px solid rgba(226, 80, 63, 0.3);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.8rem;
}

/* -- States ------------------------------------------------------ */
.empty, .loading {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  animation: rise 0.5s both;
}
.empty .big { font-family: var(--display); font-size: 1.5rem; color: var(--cream); margin-bottom: 0.4rem; }

/* -- Toasts ------------------------------------------------------ */
.toasts { position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: 50; display: flex; flex-direction: column; gap: 0.6rem; }
.toast {
  font-size: 0.92rem;
  background: var(--raised-2);
  color: var(--cream);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--ball);
  border-radius: var(--r-sm);
  padding: 0.8rem 1.1rem;
  box-shadow: var(--shadow);
  animation: slide-in 0.3s both;
  max-width: 320px;
}
.toast.err { border-left-color: var(--red); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* -- Modal / themed confirm dialog -------------------------------- */
.hidden { display: none !important; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: color-mix(in srgb, var(--ink) 68%, transparent);
  backdrop-filter: blur(3px);
  animation: fade 0.15s both;
}
.modal-box {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.6rem;
  animation: rise 0.22s both;
}
.modal-sm { max-width: 380px; }
.modal-box h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--cream);
}
.modal-subtitle { color: var(--muted); font-size: 0.92rem; line-height: 1.5; margin-top: 0.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.5rem; }
.modal-actions-spread { justify-content: space-between; }
.modal-actions-right { display: flex; gap: 0.6rem; }

.muted-note { color: var(--faint); font-family: var(--mono); font-size: 0.72rem; margin-top: 0.8rem; margin-bottom: 1.2rem; letter-spacing: 0.04em; }

.modal-note {
  font-size: 0.8rem;
  color: var(--faint);
  font-style: italic;
  margin: 0.4rem 0 0.8rem;
}

.modal-match-info {
  font-size: 0.92rem;
  line-height: 1.7;
  margin: 0.4rem 0 0.2rem;
}

.system-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  vertical-align: middle;
  margin-left: 4px;
  cursor: help;
}

/* ≤768px: hide the court-outline lines -- on a phone the rectangle sits ~20px
   from every edge and reads as a UI frame boxing in the content. The gradient
   atmosphere in .court-lines itself is kept; only the pseudo-element lines go. */
@media (max-width: 768px) {
  .court-lines::before,
  .court-lines::after { content: none; }
}

/* ≤768px: two-row topbar (mirrors CoolCourts Ladder's pattern).
   Row 1: brand (left, flex:1) + nav-actions (right, shrink-wrapped).
   Row 2: nav page links, full-width, horizontally scrollable -- no word-wrap,
   no squished brand, no overflowing buttons regardless of how many nav items exist. */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0 1rem;
    gap: 0;
  }
  .brand {
    flex: 1;          /* fills row 1 alongside nav-actions */
    padding: 0.625rem 0;
  }
  .brand-name { font-size: 1.15rem; }
  .nav-actions {
    margin-left: 0;
    border-left: 0;
    padding-left: 0;
    padding: 0.35rem 0;
    gap: 0.15rem;
  }
  /* Email hidden on mobile -- not enough room and not critical. */
  .who { display: none; }

  /* Nav links: push to row 2, full width, scroll sideways. */
  .nav {
    order: 10;
    width: 100%;
    flex: none;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--line);
    flex-wrap: nowrap;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav button {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.65rem 1rem;
    border-radius: 0;
    font-size: 0.9rem;
  }
  .nav a.active { border-radius: 0; }
}

/* ≤640px: week grid is impractical (7 days × courts × 104px cols = ~2,200px+).
   The JS in renderBook() also forces day view when this breakpoint is active. */
@media (max-width: 640px) {
  [data-style="week"] { display: none; }
}

@media (max-width: 560px) {
  .controls { flex-direction: column; align-items: stretch; }

  /* Toasts: stretch to full width so they don't clip at 320px. */
  .toasts { left: 0.9rem; right: 0.9rem; bottom: 0.9rem; }
  .toast { max-width: 100%; }

  /* Modal: reduce overlay padding so the box has maximum room on small phones. */
  .modal-overlay { padding: 0.75rem; }
  .modal-box { padding: 1.1rem 1.2rem; }

  /* Admin hours row: let the time inputs wrap below the day checkbox. */
  .hours-row { flex-wrap: wrap; }
}
