/* Spielklingel – layout and components on top of Pico.css. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- tokens ------------------------------------------------------------------------------ */

:root {
  --sk-teal: #04a098;
  --sk-teal-dark: #037f79;
  --sk-blue: #10537e;
  --sk-green: #62b22e;
  --sk-red: #d14343;
  --sk-amber: #d98a00;

  --sk-bg: #f4f7f8;
  --sk-surface: #ffffff;
  --sk-border: #e1e7ea;
  --sk-text: #1d2a33;
  --sk-muted: #62717b;
  --sk-tint: rgba(4, 160, 152, 0.08);
  --sk-shadow: 0 1px 2px rgba(16, 34, 46, 0.05), 0 4px 16px rgba(16, 34, 46, 0.05);
  --sk-radius: 14px;
  --sk-radius-sm: 10px;

  /* Pico: fixed 16 px base instead of scaling up to 131 % on wide screens */
  --pico-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pico-font-size: 100%;
  --pico-line-height: 1.55;
  --pico-font-weight: 400;
  --pico-border-radius: var(--sk-radius-sm);
  --pico-form-element-spacing-vertical: 0.55rem;
  --pico-form-element-spacing-horizontal: 0.85rem;
  --pico-spacing: 1rem;
  --pico-typography-spacing-vertical: 0.9rem;
  --pico-block-spacing-vertical: 1.25rem;
  --pico-block-spacing-horizontal: 1.5rem;
}
:root:not([data-theme="dark"]) {
  --pico-background-color: var(--sk-bg);
  --pico-color: var(--sk-text);
  --pico-muted-color: var(--sk-muted);
  --pico-muted-border-color: var(--sk-border);
  --pico-card-background-color: var(--sk-surface);
  --pico-card-sectioning-background-color: var(--sk-surface);
  --pico-card-box-shadow: var(--sk-shadow);
  --pico-form-element-background-color: #fff;
  --pico-form-element-border-color: #d3dce1;
  --pico-primary: var(--sk-teal-dark);
  --pico-primary-background: var(--sk-teal);
  --pico-primary-border: var(--sk-teal);
  --pico-primary-hover: var(--sk-teal);
  --pico-primary-hover-background: var(--sk-teal-dark);
  --pico-primary-hover-border: var(--sk-teal-dark);
  --pico-primary-underline: rgba(4, 160, 152, 0.4);
  --pico-primary-focus: rgba(4, 160, 152, 0.25);
  --pico-primary-inverse: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sk-bg: #10151b;
    --sk-surface: #171e26;
    --sk-border: #26313d;
    --sk-text: #e4eaee;
    --sk-muted: #93a3ae;
    --sk-tint: rgba(4, 160, 152, 0.14);
    --sk-shadow: none;
    --pico-background-color: var(--sk-bg);
    --pico-color: var(--sk-text);
    --pico-muted-color: var(--sk-muted);
    --pico-muted-border-color: var(--sk-border);
    --pico-card-background-color: var(--sk-surface);
    --pico-card-sectioning-background-color: var(--sk-surface);
    --pico-card-box-shadow: none;
    --pico-form-element-background-color: #10151b;
    --pico-form-element-border-color: #33404d;
    --pico-primary: #3cc7bf;
    --pico-primary-background: var(--sk-teal);
    --pico-primary-border: var(--sk-teal);
    --pico-primary-hover-background: var(--sk-teal-dark);
    --pico-primary-inverse: #fff;
  }
}

/* --- base -------------------------------------------------------------------------------- */

body { background: var(--sk-bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { letter-spacing: -0.015em; font-weight: 700; color: var(--sk-text); }
h1 { font-size: 1.75rem; margin-bottom: 0.35rem; }
h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }
hgroup { margin-bottom: 1.25rem; }
hgroup > :not(:first-child):last-child { color: var(--sk-muted); font-size: 1rem; }
small, .small-text { font-size: 0.8125rem; }
code { font-size: 0.85em; padding: 0.1rem 0.35rem; border-radius: 6px; }
a { text-underline-offset: 0.18em; }
:where(button, [role="button"], input[type="submit"]) { font-weight: 600; font-size: 0.9375rem; }
:where(input, select, textarea) { font-size: 0.9375rem; }
label { font-size: 0.875rem; font-weight: 500; }
label small, fieldset small { font-weight: 400; color: var(--sk-muted); }

.container { max-width: 1120px; }
body.public .container { max-width: 960px; }
main.container { padding-block: 1.5rem 3rem; }

.muted { color: var(--sk-muted); }
.ok { color: var(--sk-green); }
.error { color: var(--sk-red); }

/* --- header / footer --------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--sk-surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--sk-border);
}
.site-header nav { padding-block: 0.35rem; flex-wrap: wrap; gap: 0 1rem; }
.site-header nav ul { gap: 0.15rem; flex-wrap: wrap; }
.site-header nav li { padding: 0.35rem 0.15rem; }
.site-header nav a:not(.brand) {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--sk-muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  margin: 0;
}
.site-header nav a:not(.brand):hover { color: var(--sk-text); background: var(--sk-tint); }
.site-header nav a[aria-current="page"] { color: var(--sk-teal-dark); background: var(--sk-tint); }
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
  color: var(--sk-text) !important; text-decoration: none;
}
.brand img { border-radius: 8px; }
.site-footer { padding-block: 1.5rem 2.5rem; text-align: center; color: var(--sk-muted); }
.site-footer a { color: var(--sk-muted); }

/* --- cards and layout -------------------------------------------------------------------- */

article, .card {
  background: var(--sk-surface);
  border: 1px solid var(--sk-border);
  border-radius: var(--sk-radius);
  box-shadow: var(--sk-shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
article > :last-child, .card > :last-child { margin-bottom: 0; }
.card-flush { padding: 0; overflow: hidden; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: 0.25rem 0 0; color: var(--sk-muted); }
.page-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-2 > article { margin-bottom: 0; }
.stack > * + * { margin-top: 1.25rem; }

.hero { padding-block: 0.5rem 0.25rem; }
.hero h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.4rem); line-height: 1.15; margin-bottom: 0.5rem; }
.hero p { color: var(--sk-muted); font-size: 1.05rem; max-width: 40rem; }

/* --- buttons ----------------------------------------------------------------------------- */

button, [role="button"] { border-radius: var(--sk-radius-sm); }
button.small, [role="button"].small { padding: 0.3rem 0.7rem; font-size: 0.8125rem; width: auto; }
button.danger, [role="button"].danger { background: var(--sk-red); border-color: var(--sk-red); color: #fff; }
button.danger:hover { filter: brightness(0.92); }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.btn-row > * { margin: 0; width: auto; }
form.inline { display: inline-flex; gap: 0.5rem; align-items: center; margin: 0; }
form.inline input:not([type="checkbox"], [type="radio"]) { margin: 0; width: auto; }
label.checkbox { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
label.checkbox input { margin: 0; }
label.checkbox.small { font-size: 0.8125rem; }

/* --- badges and notices ------------------------------------------------------------------ */

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: color-mix(in srgb, var(--sk-muted) 14%, transparent); color: var(--sk-muted);
  vertical-align: middle; margin-right: 0.25rem;
}
.badge::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.badge-ok { background: color-mix(in srgb, var(--sk-green) 16%, transparent); color: #3f7f17; }
.badge-offline { background: color-mix(in srgb, var(--sk-red) 14%, transparent); color: var(--sk-red); }
.badge-battery_low { background: color-mix(in srgb, var(--sk-amber) 16%, transparent); color: #a86b00; }

.flash {
  padding: 0.7rem 1rem; border-radius: var(--sk-radius-sm); margin-bottom: 1.25rem; font-size: 0.9rem;
  border: 1px solid; background: var(--sk-surface);
}
.flash.ok { color: #2f6b0c; border-color: color-mix(in srgb, var(--sk-green) 45%, transparent);
  background: color-mix(in srgb, var(--sk-green) 9%, var(--sk-surface)); }
.flash.error { color: var(--sk-red); border-color: color-mix(in srgb, var(--sk-red) 40%, transparent);
  background: color-mix(in srgb, var(--sk-red) 7%, var(--sk-surface)); }
.notice { border-left: 3px solid var(--sk-blue); padding: 0.6rem 1rem; background: rgba(16, 83, 126, 0.06);
  border-radius: 0 var(--sk-radius-sm) var(--sk-radius-sm) 0; font-size: 0.9rem; }
.field-error { color: var(--sk-red); display: block; margin-top: -0.5rem; margin-bottom: 0.75rem; }

/* --- search and playground list ---------------------------------------------------------- */

.search { position: relative; margin-bottom: 1rem; }
/* Pico styles [role=search] as an input group (square inner corners, -1px margin); undo that. */
.search[role="search"] { display: block; box-shadow: none; border-radius: var(--sk-radius); }
.search[role="search"] > input[type="search"] {
  width: 100%; margin: 0; padding-left: 2.6rem;
  border-radius: var(--sk-radius); background-color: var(--sk-surface);
}
.search svg { position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--sk-muted); pointer-events: none; }

.pg-list { list-style: none; padding: 0; margin: 0; }
.pg-list li { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--sk-border); }
.pg-list li:last-child { border-bottom: none; }
.pg-item { display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 1.1rem; text-decoration: none; color: inherit; }
a.pg-item:hover { background: var(--sk-tint); }
.pg-thumb {
  flex: none; width: 48px; height: 48px; border-radius: 12px; object-fit: cover;
  background: var(--sk-tint); color: var(--sk-teal); display: grid; place-items: center;
}
.pg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pg-text strong { font-weight: 600; color: var(--sk-text); }
.pg-text span { font-size: 0.85rem; color: var(--sk-muted); }
.pg-chevron { color: var(--sk-muted); flex: none; }
.pg-item button { margin: 0; }
.empty { padding: 1.5rem; text-align: center; color: var(--sk-muted); margin: 0; }

/* --- playground page --------------------------------------------------------------------- */

.pg-layout { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.pg-layout > aside { position: sticky; top: 5rem; }
@media (max-width: 820px) {
  .pg-layout { grid-template-columns: 1fr; }
  .pg-layout > aside { position: static; order: -1; }
}
.location { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--sk-muted); font-size: 0.95rem; }
.playground-photo { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--sk-radius); display: block; margin-bottom: 1.25rem; }

.push-card { border-color: color-mix(in srgb, var(--sk-teal) 35%, var(--sk-border)); background: linear-gradient(180deg, var(--sk-tint), transparent 70%), var(--sk-surface); }
.push-card .push-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--sk-teal); color: #fff; display: grid; place-items: center; margin-bottom: 0.75rem; }
.push-card h2 { margin-bottom: 0.35rem; }
.push-card p { font-size: 0.925rem; }
.push-card button { width: 100%; }
.push-card ol { padding-left: 1.2rem; font-size: 0.925rem; }
.push-card .fineprint { font-size: 0.8rem; color: var(--sk-muted); margin: 0.75rem 0 0; }
.status-on { display: flex; gap: 0.5rem; align-items: flex-start; color: #2f6b0c; font-weight: 500; }

/* --- maps (Leaflet) ---------------------------------------------------------------------- */

.map { height: 320px; border-radius: var(--sk-radius); margin: 0 0 1.25rem; z-index: 0; border: 1px solid var(--sk-border); }
.map-overview { height: 340px; }
.map-pick { height: 320px; cursor: crosshair; margin-top: 0.5rem; }
/* Pico styles role="button" links; restore Leaflet's own controls. */
.leaflet-container .leaflet-bar a[role="button"],
.leaflet-container .leaflet-bar a {
  width: 30px; height: 30px; line-height: 30px; padding: 0; margin: 0;
  font-size: 18px; font-weight: 700; border-radius: 0; border: none; box-shadow: none;
  border-bottom: 1px solid #ccc; background: #fff; color: #333; text-decoration: none;
}
.leaflet-container .leaflet-bar a:last-child { border-bottom: none; }
.leaflet-container .leaflet-bar { border-radius: 8px; overflow: hidden; }
.leaflet-container { font-family: var(--pico-font-family); }
.leaflet-container a.leaflet-popup-close-button { padding: 0; }

/* --- tables ------------------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }
table { font-size: 0.875rem; margin: 0; }
table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sk-muted); font-weight: 600; }
:where(table) th, :where(table) td { padding: 0.65rem 0.8rem; background: transparent; }
table tbody tr:hover td { background: var(--sk-tint); }
table td .sub { display: block; font-size: 0.8rem; color: var(--sk-muted); }
table a { font-weight: 600; text-decoration: none; }
td.num { font-variant-numeric: tabular-nums; }
td.actions { text-align: right; }
td.actions form.inline { display: flex; justify-content: flex-end; flex-wrap: nowrap; white-space: nowrap; }
td.actions form + form { margin-top: 0.4rem; }
td.actions input:not([type="checkbox"]) { padding: 0.3rem 0.6rem; font-size: 0.8125rem; height: auto; max-width: 12rem; }
form.inline button { margin: 0; }

/* --- admin details and forms ------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: var(--sk-bg); border-radius: var(--sk-radius-sm); padding: 0.7rem 0.9rem; }
.stat span { display: block; font-size: 0.75rem; color: var(--sk-muted); font-weight: 500; }
.stat strong { font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; font-size: 0.9rem; margin: 0; }
.facts dt { color: var(--sk-muted); font-weight: 500; }
.facts dd { margin: 0; }
.qr-card { text-align: center; }
.qr-code { background: #fff; border-radius: var(--sk-radius-sm); padding: 0.5rem; display: inline-block; }
.qr-code svg { width: 200px; height: auto; display: block; }
.qr-card code { word-break: break-all; }
.thumb { max-width: 220px; border-radius: var(--sk-radius-sm); display: block; margin-bottom: 0.75rem; }
.token { word-break: break-all; }
.token-box { border-color: color-mix(in srgb, var(--sk-amber) 60%, var(--sk-border)); background: color-mix(in srgb, var(--sk-amber) 6%, var(--sk-surface)); }
.warning-box { border-left: 3px solid var(--sk-red); }
.danger-zone { border-color: color-mix(in srgb, var(--sk-red) 35%, var(--sk-border)); }
.danger-zone h2 { color: var(--sk-red); }
.narrow { max-width: 26rem; margin-inline: auto; }
.login-card { margin-top: 3rem; padding: 2rem; }
details summary { font-weight: 500; font-size: 0.9rem; }

form fieldset {
  background: var(--sk-surface); border: 1px solid var(--sk-border); border-radius: var(--sk-radius);
  box-shadow: var(--sk-shadow); padding: 1.25rem 1.5rem 0.5rem; margin-bottom: 1.25rem;
}
form fieldset legend {
  float: left; width: 100%; padding: 0; margin: 0 0 0.9rem;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
}
form fieldset legend + * { clear: both; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }
.form-actions > * { width: auto; margin: 0; min-width: 9rem; }
.form-actions [role="button"] { text-align: center; }

@media (max-width: 576px) {
  h1 { font-size: 1.5rem; }
  article, .card, form fieldset { padding: 1rem 1.1rem; }
  .site-header nav { justify-content: center; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions > * { width: 100%; }
}
.list-footer { justify-content: flex-end; border-top: 1px solid var(--sk-border); }
button.full { width: 100%; }
.btn-row.center { justify-content: center; }
form.inline.spaced { margin-bottom: 1rem; }
.btn-row [role="button"] svg, .actions [role="button"] svg { vertical-align: -3px; margin-right: 0.2rem; }
.leaflet-container .leaflet-marker-icon[role="button"] { background: none; border: 0; padding: 0; box-shadow: none; border-radius: 0; }
.grid-2 { margin-bottom: 1.25rem; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat strong { font-size: 0.975rem; }
input[type="checkbox"] { border-radius: 5px; }
.site-header button { margin: 0; }
.site-header nav ul { align-items: center; }
.form-actions > button[type="submit"], .form-actions > [role="button"] { width: auto; flex: 0 0 auto; }
input[type="file"]::file-selector-button {
  background: var(--sk-tint); color: var(--sk-teal-dark); border: 1px solid color-mix(in srgb, var(--sk-teal) 40%, transparent);
  border-radius: 8px; padding: 0.35rem 0.8rem; font-weight: 600; font-size: 0.85rem; margin-right: 0.75rem;
}
.warning-box ul { font-size: 0.9rem; margin: 0; }
@media (max-width: 700px) {
  .hide-sm { display: none; }
  .site-header nav ul:last-child { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .site-header nav ul:last-child li { flex: none; }
}
.admin article form > button[type="submit"], .admin article form .grid + button[type="submit"] { width: auto; min-width: 9rem; }
.admin article form > button.full { width: 100%; }

/* --- confirmation popover ---------------------------------------------------------------- */

.btn-row.end { justify-content: flex-end; }
td.actions .btn-row { margin-top: 0.4rem; }
td.actions > :first-child { margin-top: 0; }
.confirm-pop {
  width: min(26rem, calc(100vw - 2rem)); margin: auto; padding: 1.25rem 1.5rem;
  border: 1px solid var(--sk-border); border-radius: var(--sk-radius);
  background: var(--sk-surface); color: var(--sk-text); text-align: left; white-space: normal;
  box-shadow: 0 20px 50px rgba(16, 34, 46, 0.25);
}
.confirm-pop::backdrop { background: rgba(16, 34, 46, 0.35); backdrop-filter: blur(2px); }
.confirm-pop h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.confirm-pop p { font-size: 0.9rem; color: var(--sk-muted); margin-bottom: 1.1rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin: 0; }
.confirm-actions button { margin: 0; width: auto; }
td.actions .btn-row { flex-wrap: nowrap; }
button.small, [role="button"].small { white-space: nowrap; }
.facts dd code { word-break: break-all; }
@media (max-width: 576px) {
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.5rem; }
}
@media (max-width: 700px) {
  td.actions .btn-row { flex-direction: column; align-items: flex-end; gap: 0.35rem; }
}
.setup-box { border-left-color: var(--sk-amber); }
.setup-box ul { margin-bottom: 0.9rem; }
.btn-row input.grow { flex: 1 1 16rem; margin: 0; width: auto; }
.form-actions { margin-bottom: 1.5rem; }
