/* ─────────────────────────────────────────────────────────────────────────
   Gezinskalender – kiosk UI for a 15" touchscreen (1920×1080), also usable on a phone.
   Everything scales from the root font-size so it stays readable at arm's length.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    --bg: #F4F1EB;
    --surface: #FFFFFF;
    --surface-2: #FAF8F4;
    --ink: #1F2328;
    --ink-2: #4B5563;
    --muted: #8A8F98;
    --line: #E6E1D8;
    --accent: #3F7FD9;
    --accent-ink: #FFFFFF;
    --danger: #D9534F;
    --ok: #4CAF7D;
    --radius: 1.2rem;
    --radius-sm: 0.7rem;
    --rail-w: 6.2rem;
    --gap: 1.1rem;
    --shadow: 0 1px 2px rgba(31, 35, 40, .04), 0 6px 20px rgba(31, 35, 40, .05);
    --touch: 3.2rem;
    font-size: clamp(15px, 1.05vw, 22px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body { user-select: none; }
input, textarea { user-select: text; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; line-height: 1.1; }
h2 { font-size: 1.25rem; }
h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }

/* ── shell ─────────────────────────────────────────────────────────────── */

.kiosk {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr;
    height: 100vh;
    height: 100dvh;
}

.rail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: .35rem;
    padding: .9rem .55rem;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    min-height: 4.6rem;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.rail-item svg { width: 1.7rem; height: 1.7rem; }
.rail-item:active { background: var(--surface-2); }
.rail-item.active { background: var(--ink); color: #fff; }
.rail-item--soon { opacity: .45; }
.rail-spacer { flex: 1; }

.stage {
    padding: 1.4rem 1.6rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── common blocks ─────────────────────────────────────────────────────── */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: 1.1rem;
}
.eyebrow {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: .25rem;
}
.clock {
    font-size: 2.6rem;
    font-weight: 300;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.sub { color: var(--muted); font-weight: 500; font-size: .95rem; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem 1.3rem;
    min-width: 0;
}

.empty, .soon, .hint { color: var(--muted); font-size: .95rem; line-height: 1.4; }
.soon::before { content: "✦ "; }
.hint a { font-weight: 600; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: var(--touch);
    padding: 0 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn svg { width: 1.2rem; height: 1.2rem; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-icon { width: var(--touch); padding: 0; }
.btn-sm { min-height: 2.5rem; padding: 0 .9rem; font-size: .9rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem .65rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.chip .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--c, var(--muted)); }

.banner {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}
.banner-ok { background: color-mix(in srgb, var(--ok) 15%, white); color: #1f6b44; }
.banner-error { background: color-mix(in srgb, var(--danger) 12%, white); color: #9b2c28; }
.banner-info { background: color-mix(in srgb, var(--accent) 12%, white); color: #24518f; }

.skeleton {
    height: 1.2rem;
    border-radius: .4rem;
    background: linear-gradient(90deg, var(--surface-2), #efece6, var(--surface-2));
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    margin: .5rem 0;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── events ────────────────────────────────────────────────────────────── */

.event-list { display: flex; flex-direction: column; gap: .5rem; }

.event {
    display: grid;
    grid-template-columns: 4.6rem 1fr;
    gap: .8rem;
    align-items: center;
    padding: .55rem .8rem .55rem 0;
    border-left: .38rem solid var(--c, var(--muted));
    border-radius: .35rem;
    background: color-mix(in srgb, var(--c, var(--muted)) 7%, white);
    min-height: 3.2rem;
}
.event-time { font-variant-numeric: tabular-nums; font-weight: 700; padding-left: .8rem; font-size: .95rem; }
.event-time small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.event-title { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.event-meta { color: var(--muted); font-size: .8rem; margin-top: .1rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.event-meta .who { color: var(--c, var(--muted)); font-weight: 700; }

.event-compact {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    padding: .35rem 0;
    border-bottom: 1px dashed var(--line);
    font-size: .95rem;
}
.event-compact:last-child { border-bottom: 0; }
.event-compact .dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--c); flex: none; transform: translateY(-1px); }
.event-compact .t { font-variant-numeric: tabular-nums; color: var(--ink-2); flex: none; min-width: 3.2rem; }

/* ── Today ─────────────────────────────────────────────────────────────── */

.today-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(20rem, 5fr) 7fr;
    gap: var(--gap);
}
.agenda { display: flex; flex-direction: column; overflow: auto; }
.agenda h2 { margin-bottom: .8rem; display: flex; align-items: baseline; gap: .6rem; }
.agenda .mt { margin-top: 1.4rem; }

.kids {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: var(--gap);
    min-height: 0;
}
.kid {
    --kid: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: .45rem solid var(--kid);
    overflow: auto;
}
.kid-head { display: flex; align-items: center; gap: .8rem; }
.avatar {
    width: 3.2rem; height: 3.2rem;
    border-radius: 50%;
    background: var(--kid);
    color: #fff;
    font-weight: 700;
    font-size: 1.4rem;
    display: grid; place-items: center;
    flex: none;
}
.avatar-sm { width: 2.2rem; height: 2.2rem; font-size: 1rem; }
.kid-section { display: flex; flex-direction: column; gap: .5rem; }
.kid-section h3 { margin-bottom: .15rem; }

.msg-row {
    display: flex; flex-direction: column; gap: .15rem;
    padding: .55rem .7rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.msg-row .s { font-weight: 600; line-height: 1.25; }
.msg-row .m { color: var(--muted); font-size: .8rem; }

/* ── Week ──────────────────────────────────────────────────────────────── */

.week-nav { display: flex; align-items: center; gap: .5rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; }

.week-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .7rem;
}
.day {
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.day-head {
    padding: .8rem .9rem .6rem;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: baseline; justify-content: space-between;
}
.day-head .n { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.day-head .d { color: var(--muted); font-weight: 600; text-transform: capitalize; }
.day.today .day-head { background: var(--ink); color: #fff; }
.day.today .day-head .d { color: rgba(255,255,255,.75); }
.day.past { opacity: .6; }
.day-body { padding: .6rem .6rem; overflow: auto; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.day-body .empty { padding: .4rem .3rem; font-size: .85rem; }

.wevent {
    border-left: .32rem solid var(--c, var(--muted));
    background: color-mix(in srgb, var(--c, var(--muted)) 9%, white);
    border-radius: .35rem;
    padding: .4rem .55rem;
    font-size: .88rem;
    line-height: 1.25;
}
.wevent .t { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: .3rem; }
.wevent .who { display: block; color: var(--c); font-size: .72rem; font-weight: 700; }

/* ── Messages ──────────────────────────────────────────────────────────── */

.msgs { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(20rem, 2fr) 3fr; gap: var(--gap); }
.msg-list { display: flex; flex-direction: column; overflow: auto; padding: .6rem; gap: .3rem; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.filter {
    min-height: 2.6rem; padding: 0 1rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: .5rem;
}
.filter .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--c, var(--muted)); }
.filter.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.msg-item {
    display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center;
    padding: .7rem .8rem; border-radius: var(--radius-sm); cursor: pointer; min-height: 3.6rem;
    border: 1px solid transparent;
}
.msg-item:active, .msg-item.active { background: var(--surface-2); border-color: var(--line); }
.msg-item .s { font-weight: 600; line-height: 1.25; }
.msg-item .m { color: var(--muted); font-size: .8rem; }
.msg-item .d { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }

.msg-reader { overflow: auto; user-select: text; }
.msg-reader .body { margin-top: 1rem; line-height: 1.5; font-size: 1rem; }
.msg-reader .body img { max-width: 100%; }
.msg-reader .body table { max-width: 100%; }

/* ── Settings ──────────────────────────────────────────────────────────── */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: var(--gap); align-content: start; overflow: auto; }
.tile { display: flex; flex-direction: column; gap: .6rem; text-decoration: none; color: inherit; min-height: 9rem; }
.tile svg { width: 1.8rem; height: 1.8rem; color: var(--accent); }
.tile .big { font-size: 1.9rem; font-weight: 700; }

.list { display: flex; flex-direction: column; gap: .6rem; overflow: auto; }
.row {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem;
}
.row .grow { flex: 1; min-width: 12rem; }
.row .title { font-weight: 650; }
.row .meta { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field .help { color: var(--muted); font-size: .8rem; }
.input {
    min-height: var(--touch); padding: 0 .9rem; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface); font: inherit; width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch {
    width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 3px solid transparent; cursor: pointer;
    background: var(--c); padding: 0;
}
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

.switch { position: relative; width: 3.4rem; height: 2rem; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
    position: absolute; inset: 0; border-radius: 999px; background: #D8D3CA; transition: .2s; cursor: pointer;
}
.switch span::after {
    content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.6rem; height: 1.6rem; border-radius: 50%;
    background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(1.4rem); }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(31,35,40,.45); display: grid; place-items: center; z-index: 50; padding: 1rem;
}
.modal { width: min(32rem, 100%); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 1rem; }

.locked { display: grid; place-items: center; text-align: center; gap: 1rem; padding: 3rem 1rem; }
.locked svg { width: 3rem; height: 3rem; color: var(--muted); }

/* ── PIN pad (login / unlock, static pages) ────────────────────────────── */

.pin-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.pin-card { width: min(24rem, 100%); text-align: center; }
.pin-card h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.pin-dots { display: flex; justify-content: center; gap: .7rem; margin: 1.3rem 0; min-height: 1rem; }
.pin-dots i { width: .9rem; height: .9rem; border-radius: 50%; border: 2px solid var(--ink); display: block; }
.pin-dots i.on { background: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.pin-key {
    min-height: 4rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
    font: inherit; font-size: 1.6rem; font-weight: 600; cursor: pointer;
}
.pin-key:active { background: var(--line); }
.pin-key.ok { background: var(--ink); color: #fff; border-color: var(--ink); font-size: 1.1rem; }
.pin-key.clr { font-size: 1rem; color: var(--ink-2); }

/* ── Blazor bits ───────────────────────────────────────────────────────── */

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #fff3cd; color: #664d03; padding: .8rem 1.2rem; box-shadow: 0 -2px 8px rgba(0,0,0,.1);
}
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ── phone ─────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    :root { font-size: 16px; --rail-w: 0; }
    .kiosk { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .rail { flex-direction: row; order: 2; border-right: 0; border-top: 1px solid var(--line); padding: .4rem; }
    .rail-item { flex: 1; min-height: 3.6rem; font-size: .7rem; }
    .rail-spacer { display: none; }
    .stage { overflow: auto; padding: 1rem; }
    .today-grid, .msgs { display: flex; flex-direction: column; }
    .kids { grid-auto-flow: row; grid-auto-columns: unset; }
    .week-grid { display: flex; flex-direction: column; }
    .day-body { overflow: visible; }
    .clock { font-size: 1.8rem; }
    h1 { font-size: 1.5rem; }
}
