/*
 * Kiosk / wall view variant — the /h/:slug page, rendered by
 * layouts/wall.html.erb with <body class="kiosk">. Propshaft serves this file
 * alongside application.css (stylesheet_link_tag :app loads both), so every
 * rule here is scoped to body.kiosk and is inert on the normal app.
 *
 * Goal: readable from across the room on a wall-mounted tablet — large type,
 * cards that fill the viewport with no scrolling — and safe to leave on for
 * years: wall_drift_controller.js keeps colour, tone and position slowly
 * moving so nothing burns in. Status and availability chips read the
 * --status-* / --danger tokens set here, per tone.
 */

body.kiosk {
  color-scheme: dark;

  /* The surfaces follow wall_drift_controller.js (--drift-* on <html>):
     tinted with each member's colour in turn, easing between dark and light.
     The fallbacks are the dark board it starts as. */
  --bg: var(--drift-bg, #0d1117);
  --surface: var(--drift-surface, #161b22);
  --surface-sunken: var(--drift-surface-sunken, #1e2531);
  --border: var(--drift-border, #262d38);
  --border-strong: var(--drift-border-strong, #303a47);
  --accent: var(--drift-accent, #8ba4ff);
  --accent-fg: var(--drift-accent-fg, #0d1117);
  --accent-soft: var(--drift-accent-soft, rgba(139, 164, 255, 0.16));

  /* Text and chips switch as a set with the tone (data-wall-tone, below):
     dark-board values here, whatever the OS theme. */
  --text: #f0f3f6;
  --text-muted: #9aa7b8;
  --status-planned: #93c5fd;
  --status-planned-bg: rgba(37, 99, 235, 0.16);
  --status-planned-border: rgba(147, 197, 253, 0.35);
  --status-in_progress: #fcd34d;
  --status-in_progress-bg: rgba(217, 119, 6, 0.18);
  --status-in_progress-border: rgba(252, 211, 77, 0.35);
  --status-undone: #cbd5e1;
  --status-undone-bg: rgba(100, 116, 139, 0.2);
  --status-undone-border: rgba(203, 213, 225, 0.3);
  --status-completed: #86efac;
  --status-completed-bg: rgba(22, 163, 74, 0.16);
  --status-completed-border: rgba(134, 239, 172, 0.35);
  --danger: #fca5a5;
  --danger-bg: rgba(220, 38, 38, 0.18);
  --danger-border: rgba(248, 113, 113, 0.4);
  --wall-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  /* Colours move with the drift's tick, linearly, so its steps join into
     one continuous change; a tone switch shortens the tick to a quick fade
     (wall_drift_controller.js). Text uses the same timing as the surfaces
     behind it, so the two can never pass each other mid-fade. */
  --wall-fade: var(--drift-tick, 10s) linear;
  --wall-drift: var(--drift-tick, 10s) linear;

  margin: 0;
  min-height: 100vh;
  /* Two soft glows in the family's colours wander behind the board. */
  background:
    radial-gradient(ellipse 70vmax 55vmax at var(--drift-glow-x, 25%) var(--drift-glow-y, 20%), var(--drift-glow, transparent), transparent 70%),
    radial-gradient(ellipse 60vmax 50vmax at var(--drift-glow-2-x, 76%) var(--drift-glow-2-y, 80%), var(--drift-glow-2, transparent), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

/* The light half of the drift. Light-theme values from application.css's
   :root, restated because the OS may be in dark mode. */
html[data-wall-tone="light"] body.kiosk {
  color-scheme: light;
  --text: #16202c;
  --text-muted: #556274;
  --status-planned: #1d4ed8;
  --status-planned-bg: rgba(37, 99, 235, 0.1);
  --status-planned-border: rgba(37, 99, 235, 0.3);
  --status-in_progress: #92400e;
  --status-in_progress-bg: rgba(217, 119, 6, 0.12);
  --status-in_progress-border: rgba(217, 119, 6, 0.35);
  --status-undone: #475569;
  --status-undone-bg: rgba(100, 116, 139, 0.12);
  --status-undone-border: rgba(100, 116, 139, 0.3);
  --status-completed: #166534;
  --status-completed-bg: rgba(22, 163, 74, 0.1);
  --status-completed-border: rgba(22, 163, 74, 0.3);
  --danger: #b91c1c;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --danger-border: rgba(220, 38, 38, 0.3);
  --wall-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

/* Once the drift is running, every colour change eases instead of
   snapping (not before, so opening the wall doesn't fade in). */
html.wall-drift body.kiosk,
html.wall-drift body.kiosk * {
  transition:
    background-color var(--wall-drift),
    border-color var(--wall-drift),
    box-shadow var(--wall-drift),
    color var(--wall-fade);
}
/* The board orbits a few pixels (--drift-x/y) so nothing holds one spot.
   `translate` composes with wall_fit_controller.js's transform: scale. */
body.kiosk .wall-board { translate: var(--drift-x, 0) var(--drift-y, 0); }
html.wall-drift body.kiosk .wall-board {
  transition:
    translate var(--wall-drift),
    background-color var(--wall-drift),
    border-color var(--wall-drift),
    color var(--wall-fade);
}

/* The wall has no nav chrome, and the grid is full-bleed. */
body.kiosk nav,
body.kiosk .nav,
body.kiosk .flash-stack { display: none; }

body.kiosk .container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

body.kiosk .dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: clamp(1rem, 2vw, 1.75rem);
  padding: clamp(1rem, 2vw, 1.75rem);
  height: 100vh;
  align-items: stretch;
  align-content: stretch;
}

body.kiosk .person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--wall-shadow);
  padding: clamp(1.25rem, 2.5vw, 2rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  min-height: 0; /* let grid stretch shrink children */
}
body.kiosk .person-card::before { width: 8px; }

body.kiosk .person-identity { gap: 1rem; margin-bottom: 0; }

body.kiosk .person-avatar {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.25rem;
}

body.kiosk .person-name { font-size: clamp(1.25rem, 2vw, 1.75rem); }

body.kiosk .person-status { font-size: 1.25rem; gap: 0.75rem; }

body.kiosk .status-chip {
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  padding: 0.4375rem 1rem;
  border-width: 1px;
}
body.kiosk .status-chip::before { width: 0.625rem; height: 0.625rem; }

body.kiosk h1, body.kiosk h2 { font-size: 2rem; }

body.kiosk .person-now { font-size: clamp(1.125rem, 1.6vw, 1.375rem); }
body.kiosk .person-next { font-size: 1.125rem; }

/* Names link to profiles in the app; the wall is read-only, so they're inert
   here. They take the text colour as is, without a fade of their own: a
   visited link's colour transition can stall on its old value, which left
   names dark on dark cards. */
body.kiosk .person-card a,
body.kiosk .person-card a:visited { pointer-events: none; color: inherit; }
html.wall-drift body.kiosk .person-card a { transition: none; }
body.kiosk .person-where { font-size: 1.125rem; }

/* The board: a band per place someone is, top to bottom. The place's name
   sits in a fixed column on the left; its people and pets follow as
   same-size tiles, --tiles across (the same in every band, so tiles line up
   down the whole board), wrapping onto more rows when a place is busy.
   wall_fit_controller.js picks --tiles and the scale that fill the screen. */
body.kiosk .wall-board {
  --wall-gap: clamp(0.75rem, 1.5vw, 1.125rem);
  display: grid;
  align-content: start;
  gap: var(--wall-gap);
  padding: var(--wall-gap);
  transform-origin: top left;
}
body.kiosk .wall-place {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: var(--wall-gap);
  align-items: start;
  padding: var(--wall-gap);
  background: color-mix(in srgb, var(--surface) 45%, transparent);
  border: 1px solid var(--border);
  border-radius: 24px;
}
body.kiosk .wall-place-header { display: grid; justify-items: start; gap: 0.5rem; min-width: 0; padding-top: 0.25rem; }
body.kiosk .wall-place-header .place-photo { width: 3rem; border-radius: 12px; }
body.kiosk .wall-place-header .place-photo > .icon { width: 50%; height: 50%; }
/* Long place names wrap between words, never inside one. */
body.kiosk .wall-place-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: manual;
}
body.kiosk .wall-count { font-size: 0.9375rem; font-weight: 600; color: var(--text-muted); }
/* The tiles say who's here; the header's avatar stack only crowds it. */
body.kiosk .wall-here { display: none; }

body.kiosk .wall-cards {
  display: grid;
  grid-template-columns: repeat(var(--tiles, 4), minmax(0, 1fr));
  gap: 0.75rem;
}
/* Cards inside a place are compact so a whole family fits one screen: the
   section names the place, so the card drops its place line (keeping any
   note).
   People and pets share one shape so a column reads as a tidy list: the
   photo with the name centred beside it, then chips and a detail line
   across the card's full width beneath. Both cards' wrappers become
   `display: contents` so their children sit straight on this grid. */
body.kiosk .wall-place .person-card,
body.kiosk .wall-pet {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  grid-template-rows: 2.75rem;
  grid-auto-rows: auto;
  column-gap: 0.875rem;
  row-gap: 0.4375rem;
  align-items: start;
  align-content: start; /* a tile stretched to its row keeps its lines at the top */
  padding: 0.875rem 1.125rem 1rem 1.375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--wall-shadow);
}
body.kiosk .wall-place .person-identity,
body.kiosk .wall-pet-body { display: contents; }
body.kiosk .wall-cards .person-avatar {
  grid-column: 1;
  grid-row: 1;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1rem;
}
/* Below the name row, chips and details use the card's full width. */
body.kiosk .wall-place .person-card > *,
body.kiosk .wall-pet-body > * { grid-column: 1 / -1; margin: 0; }
body.kiosk .wall-place .person-meta,
body.kiosk .wall-pet .person-name { grid-column: 2; grid-row: 1; align-self: center; margin: 0; }
body.kiosk .wall-place .person-identity .birthday-cake { grid-column: 2; grid-row: 1; justify-self: end; align-self: center; }
body.kiosk .wall-place .person-name,
body.kiosk .wall-pet .person-name { font-size: clamp(1.125rem, 1.6vw, 1.375rem); }
body.kiosk .wall-place .person-where { display: none; }
body.kiosk .wall-place .person-status,
body.kiosk .wall-pet-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
body.kiosk .wall-place .status-chip { font-size: 0.9375rem; padding: 0.3125rem 0.75rem; }
/* The chips share a line; what they're doing gets its own, like a pet's "Seen". */
body.kiosk .wall-place .person-now { flex-basis: 100%; font-size: 1.0625rem; }
body.kiosk .wall-place .person-next { font-size: 1rem; }
body.kiosk .wall-pet-where { display: inline-flex; align-items: center; gap: 0.4375rem; font-size: 1rem; }
body.kiosk .wall-pet-where small { font-size: 0.9375rem; font-weight: 500; color: var(--text-muted); }

/* Inside / outside / penned up (.spot-chip) is styled in application.css,
   shared with the dashboard; in the drifting accent here, so it follows the
   board's colour and tone. */
