/*
 * El Cachino shell: the one top bar of cachino.online, play.cachino.online, track.cachino.online and
 * events.cachino.online. Master copy: Casino/shared/shell.css. `node shared/sync.mjs` copies it into the three apps;
 * the nav-consistency test fails if a copy drifts. Edit here, never in an app.
 * Left to right: the mark and the word, the app switch ("| Events"), the app's own actions, theme.
 * One row, one centre line: every item is 44px tall and centred on the bar; the word and the app name are the same
 * face at the same size, so they share a baseline too (test/nav-alignment.test.ts).
 */
/* Legal navigation stays centred across the apps; text is compact, phone targets remain 44px. 6.9: on phones the six
   links share one row whenever they fit (each still a 44px target), so the footer is one target tall instead of two;
   narrower screens wrap to centred rows with the same gap between every link. */
.credit-bar .legal-links,
.foot .foot-links,
.tr-legal.tr-legal nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 10px;
  width: 100%;
  text-align:center;
  line-height: 1.25;
}
.credit-bar .legal-links a,
.foot .foot-links a,
.tr-legal.tr-legal nav a {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  padding-block: 0;
  text-align: center;
  line-height: 1.25;
}
@media (min-width: 600px) {
  .credit-bar .legal-links, .foot .foot-links, .tr-legal.tr-legal nav { gap: 0 24px; }
  .credit-bar .legal-links a, .foot .foot-links a, .tr-legal.tr-legal nav a { flex: 0 0 auto; }
}
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .credit-bar .legal-links a, .foot .foot-links a, .tr-legal.tr-legal nav a { min-height: 24px; }
}
:root {
  --cs-h: 56px;
  /* The side inset: 16px on a phone, 32px on a laptop, 48px past 1440px. Page content uses the same one. */
  --cs-gutter: 16px;
  /* The page frame (content width, without the inset). The bar lines its mark up with the content's left edge. */
  --cs-frame: 1192px;
  /* The app menu's paper and ink: the page's own, worked out here on the root, so a bar that sets its own --ink for
     what's inside it (the Tracker's) doesn't reach the menu. */
  --cs-pop: var(--panel, var(--surface, var(--shell)));
  --cs-pop-ink: var(--ink, var(--shell-ink));
  --cs-pop-ink-2: var(--ink-2, var(--shell-ink-2));
  --cs-pop-line: var(--line, color-mix(in srgb, var(--shell-ink) 18%, transparent));
  /* The one shadow of anything that floats over the page (the app menu, the bar's hints). */
  --cs-pop-shadow: 0 18px 36px -24px rgba(0, 0, 0, 0.45);
  --font: 'Figtree', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Bricolage Grotesque', 'Figtree', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (min-width: 761px) {
  :root {
    --cs-gutter: 32px;
  }
}
@media (min-width: 1441px) {
  :root {
    --cs-gutter: 48px;
  }
}

.cs-bar {
  height: var(--cs-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--cs-gutter);
  background: var(--shell);
  color: var(--shell-ink);
  font-family: var(--font);
  min-width: 0;
}
/* Doubled class: beats each app's own bar padding. The mark starts on the page's content edge. */
/* On an iPhone with the app on the home screen the page runs up under the clock: the bar grows by that much and its
   colour fills it, so the bar sits right under the clock as in a browser (0 everywhere else). */
.cs-bar.cs-bar {
  box-sizing: border-box;
  height: calc(var(--cs-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: 0;
  padding-left: max(var(--cs-gutter), env(safe-area-inset-left, 0px), calc((100% - var(--cs-frame)) / 2));
  padding-right: max(var(--cs-gutter), env(safe-area-inset-right, 0px), calc((100% - var(--cs-frame)) / 2));
}
.cs-bar > * {
  align-self: center;
}
.cs-bar .cs-sp {
  flex: 1;
  min-width: 0;
}

/* The mark and the word Cachino: always both, the same size everywhere, the link home. */
.cs-brand,
.cs-switch {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 44px;
  margin: 0;
  color: var(--shell-ink);
  text-decoration: none;
  font: 700 18px/1 var(--font-display);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.cs-brand {
  gap: 10px;
}
.cs-word {
  display: block;
}
.cs-logo {
  flex: none;
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
.cs-logo .logo-face {
  fill: var(--shell-ink);
}
.cs-logo .logo-ink {
  fill: var(--shell);
}
.cs-logo .logo-red {
  fill: var(--accent);
}
.cs-logo .logo-ring {
  fill: none;
  stroke: var(--shell);
  stroke-width: 2;
}

/* The app switch: "| Events" and a chevron, right after the word. Same face and size as the word, lighter, so it
   reads "Cachino | Events" on one line and one baseline. It opens the app menu. No pill, no fill. */
.cs-switch {
  gap: 6px;
  padding: 0 2px 0 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--shell-ink-2);
  font-weight: 500;
  cursor: pointer;
  transition: color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-cur {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding-left: 12px;
  border-left: 1px solid color-mix(in srgb, var(--shell-ink) 35%, transparent);
}
.cs-switch .cs-chev {
  flex: none;
  display: block;
  opacity: 0.8;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-switch:hover,
.cs-switch:has(+ .cs-menu:popover-open) {
  color: var(--shell-ink);
}
.cs-switch:hover .cs-chev {
  transform: translateY(1px);
}
.cs-switch:has(+ .cs-menu:popover-open) .cs-chev {
  transform: rotate(180deg);
}
.cs-switch:focus-visible,
.cs-brand:focus-visible {
  outline: 2px solid var(--shell-ink);
  outline-offset: 2px;
  border-radius: 6px;
}

/* The app menu. A sheet of the page's own paper under the bar, a 1px line round it, a small arrow up at the switch.
   menu.js sets top (the switch's bottom + 8px), left, and the arrow. Laptop: 296px wide, on the switch's left edge.
   Phone: 16px in from both sides. Rows 48px, the same 12px above the first and below the last. */
.cs-menu {
  position: fixed;
  inset: auto;
  top: var(--cs-h);
  left: var(--cs-gutter);
  width: 296px;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 12px;
  overflow: visible;
  border: 1px solid var(--cs-pop-line);
  border-radius: 12px;
  background: var(--cs-pop);
  color: var(--cs-pop-ink);
  font-family: var(--font);
  box-shadow: var(--cs-pop-shadow);
}
.cs-menu:popover-open {
  animation: cs-menu-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cs-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
/* The arrow: a 10px square turned 45 degrees, its two top sides the menu's own line. */
.cs-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  left: calc(var(--cs-arrow, 32px) - 6px);
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--cs-pop-line);
  border-left: 1px solid var(--cs-pop-line);
  border-top-left-radius: 2px;
  background: var(--cs-pop);
  transform: rotate(45deg);
}
.cs-opts {
  display: grid;
  gap: 0;
}
.cs-opt {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 16px;
  align-items: center;
  column-gap: 12px;
  min-height: 48px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--cs-pop-ink-2);
  text-decoration: none;
  transition: background 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-opt:hover,
.cs-opt:focus-visible {
  background: color-mix(in srgb, var(--cs-pop-ink) 6%, transparent);
  outline: none;
}
.cs-opt:focus-visible {
  box-shadow: inset 0 0 0 2px var(--cs-pop-ink);
}
.cs-ico {
  display: block;
}
.cs-opt-t {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.cs-opt-n {
  font: 600 15px/1.2 var(--font);
  color: var(--cs-pop-ink);
}
.cs-opt-d {
  overflow: hidden;
  font: 400 13px/1.3 var(--font);
  color: var(--cs-pop-ink-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cs-check {
  display: block;
  visibility: hidden;
  color: var(--cs-pop-ink);
}
.cs-opt[aria-current='page'] {
  color: var(--cs-pop-ink);
}
.cs-opt[aria-current='page'] .cs-opt-n {
  font-weight: 700;
}
.cs-opt[aria-current='page'] .cs-check {
  visibility: visible;
}

/* Icon buttons in the bar (the theme switch, Settings): one look in every app. 44px square, no fill until the mouse
   rests on it, then the same 12% wash; the same focus ring; the same hint box (.cs-tip). */
.cs-theme {
  flex: none;
  display: inline-flex;
}
.cs-icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--shell-ink);
  cursor: pointer;
  transition: background 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-icon-btn:hover {
  background: color-mix(in srgb, var(--shell-ink) 12%, transparent);
}
.cs-icon-btn:active {
  transform: scale(0.98);
}
.cs-icon-btn:focus-visible {
  outline: 2px solid var(--shell-ink);
  outline-offset: -2px;
}
.cs-icon-btn svg {
  display: block;
}

/* The hint under a bar button: the app menu's paper, line and shadow, small. menu.js places it 8px under the
   button, centred on it, inside the screen. */
.cs-tip {
  position: fixed;
  z-index: 2147483000;
  max-width: min(260px, calc(100vw - 16px));
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--cs-pop-line);
  border-radius: 8px;
  background: var(--cs-pop);
  color: var(--cs-pop-ink);
  font: 500 12.5px/1.35 var(--font);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--cs-pop-shadow);
  animation: cs-menu-in 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-tip[hidden] {
  display: none;
}

/* The theme switch: Cachino or Night, one tap. The icon follows <html data-room> from the first paint: a moon to go
   to Night, a sun to go back to Cachino. */
.cs-theme-btn svg {
  grid-area: 1 / 1;
}
.cs-theme-btn .cs-sun,
:root[data-room='night'] .cs-theme-btn .cs-moon {
  display: none;
}
:root[data-room='night'] .cs-theme-btn .cs-sun {
  display: block;
}

@media (max-width: 760px) {
  .cs-bar {
    gap: 8px;
  }
  .cs-brand,
  .cs-switch {
    font-size: 17px;
  }
  .cs-brand {
    gap: 8px;
  }
  .cs-brand .cs-logo {
    width: 26px;
    height: 26px;
  }
  .cs-cur {
    padding-left: 8px;
  }
  .cs-menu {
    width: auto;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-switch,
  .cs-switch .cs-chev,
  .cs-opt,
  .cs-icon-btn {
    transition: none;
  }
  .cs-menu:popover-open,
  .cs-tip {
    animation: none;
  }
}

/* On/off buttons (Sound, Full View…): on is filled with the accent and says "On", off is an outline and says
   "Off". The icon changes too, and aria-pressed carries the state, so it never rests on colour alone. */
.cs-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: 600 14px/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-toggle:hover {
  border-color: currentColor;
}
.cs-toggle:active {
  transform: scale(0.98);
}
.cs-toggle[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Pages come in the way cachino.online's landing does: each part rises 12px and fades in, one after another, 600ms
   with the same ease. .cs-rise moves its children, .cs-rise-2 its grandchildren (a page inside <main>). Events and
   the Tracker use it on their pages; anyone who asked for less motion gets them still. */
@keyframes cs-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
.cs-rise > *,
.cs-rise-2 > * > * {
  animation: cs-rise 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.cs-rise > :nth-child(2),
.cs-rise-2 > * > :nth-child(2) {
  animation-delay: 60ms;
}
.cs-rise > :nth-child(3),
.cs-rise-2 > * > :nth-child(3) {
  animation-delay: 120ms;
}
.cs-rise > :nth-child(4),
.cs-rise-2 > * > :nth-child(4) {
  animation-delay: 180ms;
}
.cs-rise > :nth-child(n + 5),
.cs-rise-2 > * > :nth-child(n + 5) {
  animation-delay: 240ms;
}
/* A page that is one block (an event, the live room): its parts rise instead, one after another. */
.cs-rise-2 > * > :only-child {
  animation: none;
}
.cs-rise-2 > * > :only-child > * {
  animation: cs-rise 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.cs-rise-2 > * > :only-child > :nth-child(2) {
  animation-delay: 60ms;
}
.cs-rise-2 > * > :only-child > :nth-child(3) {
  animation-delay: 120ms;
}
.cs-rise-2 > * > :only-child > :nth-child(n + 4) {
  animation-delay: 180ms;
}
@media (prefers-reduced-motion: reduce) {
  .cs-rise > *,
  .cs-rise-2 > * > *,
  .cs-rise-2 > * > :only-child > * {
    animation: none;
  }
}

/* Big screens: the same page, larger, so 100% looks right without zooming the browser. Past 1680px the bar and the
   page's own content scale by --cs-zoom (each app marks its content: Online .page > main, Events main, the Tracker
   main.wrap). Overlays (dialogs, drawers, hints, the game table) are not scaled. Lengths in 100vh inside a scaled part
   are divided by --cs-zoom, so "one screen" stays one screen. menu.js measures with the scale. */
:root {
  --cs-zoom: 1;
}
@media (min-width: 1681px) {
  :root {
    --cs-zoom: 1.1;
  }
}
@media (min-width: 1921px) {
  :root {
    --cs-zoom: 1.25;
  }
}
@media (min-width: 2241px) {
  :root {
    --cs-zoom: 1.4;
  }
}
@media (min-width: 2561px) {
  :root {
    --cs-zoom: 1.6;
  }
}
.cs-bar,
.cs-scale {
  zoom: var(--cs-zoom);
}
.cs-tip {
  zoom: var(--cs-zoom);
}

@media (min-width:600px) {
 .foot .foot-in { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:12px; }
}
.foot.foot { margin-top:8px; padding-top:0; }
/* 6.9: narrow phones (where six 44px targets cannot share one row) keep two rows of three, drawn close together. Each
   link still answers a full 44px: the top row's target reaches up into the space above the footer, the bottom row's
   reaches down into its bottom padding, so no two targets overlap and the footer is about 20px shorter. */
@media (max-width: 429px) {
  .credit-bar .legal-links,
  .foot .foot-links,
  .tr-legal.tr-legal nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 10px;
    padding-top: 2px;
  }
  /* Three to a row, each a third wide; a shorter last row (five links) stays centred. */
  .credit-bar .legal-links a,
  .foot .foot-links a,
  .tr-legal.tr-legal nav a {
    position: relative;
    flex: 0 0 calc((100% - 20px) / 3);
    min-width: 0;
    min-height: 30px;
  }
  .credit-bar .legal-links a:nth-child(n + 4),
  .foot .foot-links a:nth-child(n + 4),
  .tr-legal.tr-legal nav a:nth-child(n + 4) {
    min-height: 36px;
    align-items: flex-start;
    padding-top: 3px;
  }
  .credit-bar .legal-links a::before,
  .foot .foot-links a::before,
  .tr-legal.tr-legal nav a::before {
    content: '';
    position: absolute;
    inset: -14px 0 0;
  }
  .credit-bar .legal-links a:nth-child(n + 4)::before,
  .foot .foot-links a:nth-child(n + 4)::before,
  .tr-legal.tr-legal nav a:nth-child(n + 4)::before {
    inset: 0 0 -8px;
  }
}
