/* Welcome screen (kiosk display). Everything scales with the viewport so it works on 1080p and 4K alike. */
:root {
  --accent: #4f8cff;
  --blur: 24px;
  --dim: 0.25;
  --glass: rgba(255, 255, 255, 0.13);
  --glass-strong: rgba(255, 255, 255, 0.2);
  --glass-border: rgba(255, 255, 255, 0.28);
  --glass-highlight: rgba(255, 255, 255, 0.25);
  --base-text: #ffffff;
  --text: var(--base-text);
  --font-default: "Segoe UI Variable Display", "Segoe UI", "Inter", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Gaps in px at Full HD, scaled with the screen (set per layout). */
  --tile-gap: 32;
  --footer-gap: 32;
  --logo-size: 1;
  --accent-text: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --veil: 0, 0, 0;
  --text-shadow: 0 0.15rem 1rem rgba(0, 0, 0, 0.35);
  --shadow: 0 1.2rem 3.5rem rgba(0, 0, 0, 0.35);
  --sun: #ffd166;
  --moon: #dfe6ff;
  --rain: #9fd3ff;
  --ease: cubic-bezier(0.22, 0.8, 0.2, 1);
  color-scheme: dark;
}

/* Derived text colors; repeated on elements with their own text color (see --color-weather etc.). */
:root, .weather-card, .wifi-card, .dock {
  --muted: color-mix(in srgb, var(--text) 78%, transparent);
  --faint: color-mix(in srgb, var(--text) 58%, transparent);
  --tint: color-mix(in srgb, var(--text) 8%, transparent);
  --tint-strong: color-mix(in srgb, var(--text) 16%, transparent);
}

/* Dark text (for bright background images): bright glass, white veil instead of darkening. */
body[data-tone="light"] {
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.85);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --veil: 255, 255, 255;
  --text-shadow: 0 0 1.2rem rgba(255, 255, 255, 0.8);
  --shadow: 0 1.2rem 3.5rem rgba(20, 30, 50, 0.18);
  --sun: #eb9a00;
  --moon: #56627a;
  --rain: #1b6fd6;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  /* 1rem ≈ 17px at 1080p, 34px at 4K; --size-base scales everything (layout setting "All texts"). */
  font-size: calc(clamp(12px, 1.6vmin, 48px) * var(--size-base, 1));
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

/* Header, content and dock are stacked in the normal flow, so the dock never covers the content. */
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #0b1020;
  color: var(--text);
  font-family: var(--font-base, var(--font-default));
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.hide-cursor, body.hide-cursor * { cursor: none !important; }

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* --- Background ------------------------------------------------------------ */

.bg {
  position: fixed;
  inset: -2%;
  background:
    radial-gradient(60% 70% at 15% 20%, color-mix(in srgb, var(--accent) 70%, transparent) 0%, transparent 60%),
    radial-gradient(50% 60% at 85% 25%, rgba(155, 92, 255, 0.55) 0%, transparent 60%),
    radial-gradient(70% 60% at 60% 95%, rgba(0, 194, 168, 0.45) 0%, transparent 60%),
    radial-gradient(40% 40% at 40% 50%, rgba(255, 140, 90, 0.25) 0%, transparent 70%),
    linear-gradient(160deg, #0d1330 0%, #101a3a 50%, #0a1426 100%);
  background-size: cover;
  background-position: center;
  animation: drift 60s ease-in-out infinite alternate;
}

.bg.has-image { background: center / cover no-repeat var(--bg-image); }

@keyframes drift {
  from { transform: scale(1) translate(0, 0); }
  to   { transform: scale(1.06) translate(-1%, -1%); }
}

/* Optional background video of the layout; fades in over the background image once it plays. Two players take
   turns: shortly before one reaches its end, the other starts from the beginning on top of it and fades in, so the
   loop has no hard cut (see display.js). */
.bg-videos {
  position: fixed;
  inset: 0;
  isolation: isolate;
  pointer-events: none;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--video-fade, 1s) linear;
}

.bg-video.show { opacity: 1; }
.bg-video.front { z-index: 1; }

.dim {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(var(--veil), 0.35) 0%, transparent 22%, transparent 70%, rgba(var(--veil), 0.45) 100%),
    rgba(var(--veil), var(--dim));
}

/* --- Glass ----------------------------------------------------------------- */

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
}

/* --- Top bar --------------------------------------------------------------- */

.top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2.2rem 2.8rem;
  z-index: 5;
  pointer-events: none;
}

.top > * { pointer-events: auto; }

.top-left {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.brand-logo {
  max-height: calc(4.6rem * var(--logo-size));
  max-width: calc(18rem * var(--logo-size));
  object-fit: contain;
  filter: drop-shadow(0 0.2rem 0.8rem rgba(0, 0, 0, 0.35));
}

.weather-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1.2rem 0.6rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font-weather_chip, inherit);
  font-size: calc(1.3rem * var(--size-weather_chip, 1));
  color: var(--color-weather_chip, var(--text));
  cursor: pointer;
}

.weather-chip .wi { width: 2.2rem; height: 2.2rem; }
.weather-chip strong { font-weight: 600; }
.weather-chip .place { color: var(--muted); font-size: 1rem; }

.clock { text-align: right; text-shadow: var(--text-shadow); }
.clock-time {
  font-family: var(--font-clock_time, inherit);
  font-size: calc(4.2rem * var(--size-clock_time, 1));
  color: var(--color-clock_time, var(--text));
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  margin-top: 0.4rem;
  font-family: var(--font-clock_date, inherit);
  font-size: calc(1.2rem * var(--size-clock_date, 1));
  color: var(--color-clock_date, var(--muted));
}

/* --- Views ----------------------------------------------------------------- */

.stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  padding: 0 4rem;
  margin-bottom: calc(var(--footer-gap) * 100vmin / 1080);
}

.view {
  grid-area: 1 / 1;
  min-height: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(1.5rem) scale(0.98);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), visibility 0s linear 0.6s;
}

.view.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), visibility 0s;
}

/* Zoomed out by display.js when the content is taller than the space between header and dock. */
.fit {
  width: 100%;
  display: grid;
  justify-items: center;
}

.card {
  position: relative;
  width: min(100%, 72rem);
  border-radius: 2.4rem;
  padding: 3.2rem 3.6rem;
  text-align: center;
}

/* --- Home: one tile per visit, side by side, all of the same height -------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  gap: calc(var(--tile-gap) * 100vmin / 1080);
  width: min(100%, 72rem);
}

.tiles.multi { width: min(100%, calc(var(--cols) * 56rem)); }

/* The six sections of a tile (headline, logo, name, text, employees, contacts) are rows of the surrounding grid, so
   tiles next to each other share the row heights: everything lines up and all tiles end up equally tall. */
.tile {
  width: auto;
  display: grid;
  grid-row: span 6;
  grid-template-rows: subgrid;
  row-gap: 0;
  align-items: start;
}

.tile .sec { min-width: 0; text-align: center; }
.tile .sec-logo { align-self: center; }

.tiles.multi .tile { padding: 2.6rem 2.2rem; border-radius: 2rem; }
.tiles.multi .people { gap: 1.2rem 1.4rem; margin-top: 2rem; }
.tiles.multi .person { width: 8.6rem; }
.tiles.multi .person .avatar { width: 5.2rem; height: 5.2rem; font-size: 1.6rem; }
.tiles.multi .people.no-avatars { gap: 0.7rem; }
.tiles.multi .people.no-avatars .person { width: auto; min-width: 9rem; }

.enter .card { animation: card-in 0.9s var(--ease) both; animation-delay: calc(var(--i, 0) * 0.12s); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(2.5rem) scale(0.96); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.enter .stagger > * { animation: rise 0.7s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(1.2rem); }
  to   { opacity: 1; transform: none; }
}

.kicker {
  font-family: var(--font-headline, inherit);
  font-size: calc(1.5rem * var(--size-headline, 1));
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-headline, var(--accent-text));
}

/* Highlighted part of a free text ("*text*", see rich() in shared.js); styled by the text element "highlight". */
.hl {
  font-family: var(--font-highlight, inherit);
  font-size: calc(1em * var(--size-highlight, 1));
  color: var(--color-highlight, var(--accent-text));
}
/* The headline already uses the accent color. */
.kicker .hl { color: var(--color-highlight, var(--text)); }

.kicker::after {
  content: "";
  display: block;
  width: 3.2rem;
  height: 0.25rem;
  margin: 0.9rem auto 0;
  border-radius: 999px;
  background: var(--accent);
}

/* zoom scales the logo together with its white card (layout setting); it never gets wider than the tile. */
.company-logo {
  display: block;
  margin: 1.6rem auto 0.4rem;
  max-width: min(32rem, calc(70% * var(--company-logo-size, 1)), 100%);
  max-height: 9rem;
  zoom: var(--company-logo-size, 1);
  object-fit: contain;
  padding: 1rem 1.6rem;
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0.6rem 1.8rem rgba(0, 0, 0, 0.2);
}

.company-name {
  --fs: 4.2rem;
  margin: 0.8rem 0 0;
  font-family: var(--font-company_name, inherit);
  font-size: calc(var(--fs) * var(--size-company_name, 1));
  color: var(--color-company_name, var(--text));
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.tiles.multi .company-name { --fs: 3.2rem; }
.tile.has-logo .company-name, .company-logo + .company-name { --fs: 2.6rem; margin-top: 1rem; }

.message {
  margin: 1.2rem auto 0;
  max-width: 48rem;
  font-family: var(--font-message, inherit);
  font-size: calc(1.5rem * var(--size-message, 1));
  color: var(--color-message, var(--muted));
  line-height: 1.45;
  text-wrap: balance;
}

.people {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.6rem 2.2rem;
  margin-top: 2.6rem;
}

.person {
  width: 10.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.people.compact .person { width: 8.6rem; }

.person .avatar {
  width: 6.4rem;
  height: 6.4rem;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 600;
  border: 0.2rem solid var(--accent);
  box-shadow: 0 0.5rem 1.4rem rgba(0, 0, 0, 0.25);
  background: var(--glass-strong);
  color: #fff;
}

.people.compact .avatar { width: 5.2rem; height: 5.2rem; font-size: 1.6rem; }

.person .name {
  margin-top: 0.8rem;
  font-family: var(--font-person_name, inherit);
  font-size: calc(1.2rem * var(--size-person_name, 1));
  color: var(--color-person_name, var(--text));
  font-weight: 600;
  line-height: 1.25;
}
.person .title {
  margin-top: 0.2rem;
  font-family: var(--font-person_title, inherit);
  font-size: calc(0.95rem * var(--size-person_title, 1));
  color: var(--color-person_title, var(--faint));
  line-height: 1.25;
}

/* Without pictures the employees are shown as name tags. */
.people.no-avatars { gap: 0.9rem; }
.people.no-avatars .person {
  width: auto;
  min-width: 11rem;
  max-width: 22rem;
  padding: 0.8rem 1.4rem;
  border-radius: 1.1rem;
  background: var(--tint);
  border: 1px solid var(--tint-strong);
}
.people.no-avatars .person .name { margin-top: 0; }

.host {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2.2rem;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
  font-family: var(--font-hosts, inherit);
  font-size: calc(1.05rem * var(--size-hosts, 1));
  color: var(--color-hosts, var(--muted));
}

.host > span:first-child { color: var(--accent-text); }
.host b { color: var(--color-hosts, var(--text)); font-weight: 600; }

.idle .company-name {
  font-family: var(--font-idle_title, inherit);
  font-size: calc(4.6rem * var(--size-idle_title, 1));
  color: var(--color-idle_title, var(--text));
}
.idle .site {
  margin-top: 0.4rem;
  font-family: var(--font-idle_site, inherit);
  font-size: calc(2rem * var(--size-idle_site, 1));
  color: var(--color-idle_site, var(--muted));
  font-weight: 500;
}
.idle .message {
  font-family: var(--font-idle_text, inherit);
  font-size: calc(1.5rem * var(--size-idle_text, 1));
  color: var(--color-idle_text, var(--muted));
}

/* --- Weather view ---------------------------------------------------------- */

.weather-card {
  --text: var(--color-weather, var(--base-text));
  width: min(100%, 78rem);
  text-align: left;
  color: var(--text);
  font-family: var(--font-weather, inherit);
  zoom: var(--size-weather, 1);
}

.wx-now {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2.2rem;
}

.wx-now .wi { width: 8rem; height: 8rem; }
.wx-temp { font-size: 6rem; font-weight: 250; line-height: 1; }
.wx-desc { font-size: 1.7rem; margin-top: 0.3rem; }
.wx-place { font-size: 1.1rem; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }

.wx-facts { display: grid; gap: 0.6rem; font-size: 1.15rem; color: var(--muted); text-align: right; }
.wx-facts b { color: var(--text); font-weight: 600; }

.wx-hours {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.6rem;
  margin-top: 2.2rem;
  padding: 1.2rem 0.6rem;
  border-radius: 1.4rem;
  background: var(--tint);
  text-align: center;
}

.wx-hours .wi { width: 2.4rem; height: 2.4rem; margin: 0.4rem auto; display: block; }
.wx-hours .h { font-size: 1rem; color: var(--muted); }
.wx-hours .t { font-size: 1.3rem; font-weight: 600; }
.wx-hours .p { font-size: 0.85rem; color: var(--rain); min-height: 1.1em; }

.wx-days {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-top: 1.2rem;
}

.wx-day {
  padding: 1.1rem 0.8rem;
  border-radius: 1.4rem;
  background: var(--tint);
  text-align: center;
}

.wx-day .d { font-size: 1.15rem; font-weight: 600; }
.wx-day .wi { width: 3rem; height: 3rem; margin: 0.5rem auto; display: block; }
.wx-day .r { font-size: 1.2rem; }
.wx-day .r span { color: var(--faint); margin-left: 0.4rem; }
.wx-day .p { font-size: 0.9rem; color: var(--rain); margin-top: 0.2rem; }

/* --- Wi-Fi view ------------------------------------------------------------ */

.wifi-card {
  --text: var(--color-wifi, var(--base-text));
  color: var(--text);
  font-family: var(--font-wifi, inherit);
  zoom: var(--size-wifi, 1);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3rem;
  align-items: center;
  text-align: left;
}

.wifi-card .kicker::after { margin-left: 0; }
.wifi-card h2 { margin: 0.6rem 0 1.6rem; font-size: 3rem; font-weight: 650; }
.wifi-row { margin-top: 1.2rem; }
.wifi-row .l { font-size: 1rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.14em; }
.wifi-row .v { font-size: 2.2rem; font-weight: 600; word-break: break-all; font-variant-ligatures: none; }
.wifi-row .v.mono { font-family: "Cascadia Mono", "SF Mono", Consolas, "Roboto Mono", monospace; letter-spacing: 0.04em; }
.wifi-note { margin-top: 1.6rem; color: var(--muted); font-size: 1.15rem; line-height: 1.4; }

.qr {
  width: 17rem;
  padding: 1rem;
  border-radius: 1.4rem;
  background: #fff;
  box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.3);
}

.qr img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-hint { margin-top: 0.8rem; font-size: 0.95rem; color: var(--muted); text-align: center; }

/* --- Dock ------------------------------------------------------------------ */

.dock {
  --text: var(--color-dock, var(--base-text));
  position: relative;
  justify-self: center;
  margin-bottom: 2.2rem;
  color: var(--text);
  font-family: var(--font-dock, inherit);
  zoom: var(--size-dock, 1);
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem;
  border-radius: 1.8rem;
  z-index: 5;
}

.dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  min-width: 7.2rem;
  padding: 0.8rem 1.2rem 0.7rem;
  border: 0;
  border-radius: 1.3rem;
  background: transparent;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s var(--ease), transform 0.2s var(--ease);
}

.dock button:active { transform: scale(0.95); }
.dock button.active { background: var(--tint-strong); }
.dock .ico svg { width: 2rem; height: 2rem; display: block; }

.dock button.active .ico { color: var(--accent-text); }
.dock button::after {
  content: "";
  width: 1.4rem;
  height: 0.3rem;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}
.dock button.active::after { opacity: 1; }

/* Progress bar showing when the screen returns to "Home". */
.dock .timeout {
  position: absolute;
  left: 1.4rem;
  right: 1.4rem;
  bottom: 0.25rem;
  height: 0.2rem;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
}

.dock .timeout.run { opacity: 1; animation: countdown linear forwards; }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* --- Weather icons --------------------------------------------------------- */

.wi { color: var(--text); overflow: visible; }
.wi .sun { color: var(--sun); }
.wi .moon { color: var(--moon); }
.wi .drop { color: var(--rain); }
.wi .bolt { color: var(--sun); }

/* --- Misc ------------------------------------------------------------------ */

.preview-badge, .offline {
  position: fixed;
  left: 50%;
  top: 1.2rem;
  transform: translateX(-50%);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  z-index: 10;
}

.preview-badge { background: rgba(255, 196, 0, 0.9); color: #222; font-weight: 600; }
.offline { top: auto; bottom: 0.6rem; background: rgba(220, 60, 60, 0.85); color: #fff; }

@media (max-aspect-ratio: 1/1) {
  /* Portrait screens (stele) */
  html { font-size: calc(clamp(12px, 2vmin, 48px) * var(--size-base, 1)); }
  .wifi-card { grid-template-columns: 1fr; text-align: center; }
  .wifi-card .kicker::after { margin-left: auto; }
  .qr { margin: 0 auto; }
  .wx-hours { grid-template-columns: repeat(4, 1fr); }
  .wx-days { grid-template-columns: repeat(3, 1fr); }
  .wx-now { grid-template-columns: auto 1fr; }
  .wx-facts { grid-column: 1 / -1; text-align: left; grid-template-columns: repeat(3, auto); justify-content: start; gap: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bg { animation: none; }
  .enter .card, .enter .stagger > * { animation-duration: 0.01s; animation-delay: 0s; }
}
