/* Konfetti Design tokens: plain light values first. Browsers without light-dark() (before Chrome 123, Safari 17.5,
   Firefox 120) stay light instead of losing every token; the toggle is hidden there (see .theme-toggle). */
:root {
    --bg: #F7F6F9;
    --surface: #FFFFFF;
    --text: #1C1A24;
    --muted: #6B6577;
    --line: #E3E0EA;
    --border: #D6D2DE;
    --cut: #1C1A24;
    --tabs-bg: #ECEAF0;
    --tab-on: #FFFFFF;
    --hover: #EDEBF1;
    --accent: #C8402E;
    --display: Unbounded, system-ui, sans-serif;
    color-scheme: light dark;
}
/* light-dark(light, dark) follows color-scheme, which the theme script pins via data-theme */
@supports (color: light-dark(#000, #fff)) {
    :root {
        --bg: light-dark(#F7F6F9, #1C1A24);
        --surface: light-dark(#FFFFFF, #26232F);
        --text: light-dark(#1C1A24, #F2F0F5);
        --muted: light-dark(#6B6577, #A8A3B3);
        --line: light-dark(#E3E0EA, #312D3B);
        --border: light-dark(#D6D2DE, #3A3646);
        --cut: light-dark(#1C1A24, #C9C4D3);
        --tabs-bg: light-dark(#ECEAF0, #26232F);
        --tab-on: light-dark(#FFFFFF, #3A3646);
        --hover: light-dark(#EDEBF1, #2A2633);
        --accent: light-dark(#C8402E, #FF4D57);
    }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 15px/1.35 Figtree, system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
}

body > * { max-width: 560px; margin-inline: auto; }

a { color: inherit; }
b { font-weight: 600; }
button { font: inherit; }

/* Wordmark: last "i" is a lightsaber */
.wordmark {
    font: 700 21px/1.1 var(--display);
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.wm-i { display: inline-block; vertical-align: baseline; width: 0.17em; margin-left: 0.04em; }
.wm-i > span { display: block; }
.wm-blade { width: 0.17em; height: 0.26em; border-radius: 0.085em; background: var(--accent); margin-bottom: 0.03em; }
.wm-collar { width: 0.23em; height: 0.035em; margin: 0 0 0.03em -0.03em; border-radius: 0.015em; background: var(--muted); }
.wm-hilt { width: 0.17em; height: 0.56em; border-radius: 0.03em; background: var(--text); }

/* Wordmark with the subtitle underneath */
.brand { display: flex; flex-direction: column; gap: 4px; }
.subtitle { font-size: 13px; font-weight: 500; letter-spacing: 0.04em; color: var(--muted); }

/* Header with view switch */
/* Header sticks (minus 14px of its top padding) while the view switch below scrolls away and fades. Then, tied to the
   scroll (--p from 0 to 1, set by the scroll script of the list page), the month bar comes up under the header, the
   header's background and texts fade, and its wordmark travels to the right end of the bar; at the end (.merged) the
   bar's own wordmark takes its place */
.top {
    position: sticky; top: -14px; z-index: 4;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 26px 20px 8px;
}
.top::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--bg); opacity: calc(1 - var(--p, 0)); }
.top .subtitle, .top .top-right { opacity: calc(1 - 2.5 * var(--p, 0)); }
.top .wordmark { transform-origin: 0 0; will-change: transform; }
.top.moving { pointer-events: none; }
.merged .top { visibility: hidden; }
.tabs-wrap { padding: 10px 20px 16px; }
.top-right { display: flex; align-items: center; gap: 4px; }
.season { font-size: 14px; color: var(--muted); }
.new, .edit {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
    font-size: 15px; font-weight: 600; text-decoration: none;
    background: none; border: none; color: inherit; cursor: pointer; /* also a <button> (Speichern on the edit page) */
}
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-right: -12px; /* the icon, not the button, lines up with the content edge */
    background: none; border: none; border-radius: 10px; color: var(--text); cursor: pointer;
}
.bar .theme-toggle { margin-right: -4px; }
:root[data-theme="dark"] .theme-toggle .moon, :root:not([data-theme="dark"]) .theme-toggle .sun { display: none; }
:root:not([data-theme]) .theme-toggle { display: none; } /* no script, no toggle */
@supports not (color: light-dark(#000, #fff)) { .theme-toggle { display: none; } } /* no dark values, no toggle */
.tabs {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px;
    background: var(--tabs-bg); border-radius: 14px;
}
.tabs a {
    display: flex; align-items: center; justify-content: center; min-height: 34px;
    border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.tabs a[aria-current] { background: var(--tab-on); color: var(--text); font-weight: 600; }

main { padding: 0 20px 28px; }

/* Month name: sticks at the top, smaller once stuck */
.month > h2 {
    position: sticky; top: 0; z-index: 3;
    display: flex; align-items: center; height: 40px; margin: 0;
    background: var(--bg); border-bottom: 1px solid transparent;
    font: 700 24px/1 var(--display); letter-spacing: -0.02em;
    transition: font-size 300ms ease, border-color 300ms ease;
}
.compact .month > h2 { height: 34px; font-size: 20px; }
.month > h2.stuck { font-size: 16px; border-bottom-color: var(--line); }
/* Year and wordmark fade in once the month name sticks */
.month > h2 .yr, .month > h2 .mw { opacity: 0; visibility: hidden; transition: opacity 400ms ease, transform 500ms cubic-bezier(.2, .8, .2, 1), filter 400ms ease, visibility 0s 500ms; }
.month > h2 .yr { margin-left: 0.4em; color: var(--muted); font-variant-numeric: tabular-nums; transform: translateX(-8px); filter: blur(3px); }
.month > h2 .mw { margin-left: auto; transform: translateX(8px); filter: blur(3px); }
.month > h2 .mw .wordmark { font-size: 16px; }
.month > h2.stuck .yr, .month > h2.stuck .mw { opacity: 1; visibility: visible; transform: none; filter: none; transition-delay: 0s, 0s, 0s, 0s; }
.month > h2.stuck .mw { transition-delay: 100ms, 100ms, 100ms, 0s; }
/* First month: size, year and wordmark follow the scroll (inline styles), so no time-based transition */
.month > h2.lead, .month > h2.lead .yr, .month > h2.lead .mw { transition: border-color 300ms ease; }
@media (prefers-reduced-motion: reduce) { .month > h2 .yr, .month > h2 .mw { transform: none; filter: none; } }

/* Event rows. scroll-margin: an event jumped to by #o<id> (back link without history) lands below the sticky month
   name, without focus ring. Hover: a soft background a little wider than the row; .sel keeps it on the event you came
   back from */
.ev, .row { position: relative; scroll-margin-top: 56px; }
.ev:target, .row:target { outline: none; }
.ev::before, .row::before {
    content: ""; position: absolute; inset: 0 -10px; z-index: -1;
    border-radius: 10px; background: var(--hover); opacity: 0; transition: opacity 350ms ease-out; /* fade out: the mark leaves softly on scroll */
}
.ev:hover::before, .row:hover::before, .ev:active::before, .row:active::before,
.ev.sel::before, .row.sel::before { opacity: 1; transition-duration: 120ms; }
.list .ev::before { inset: -4px -10px 0; }
/* Compact: the highlight hugs the text line (±6px), not the spacing a day's first or last row adds towards the rule */
.compact .row::before { top: 6px; bottom: 6px; }
.compact .day > .row:not(:only-child):first-child::before { top: 11px; bottom: -3px; }
.compact .day > .row:not(:first-child):not(:last-child)::before { top: -4px; bottom: -4px; }
.compact .day > .row:not(:only-child):last-child::before { top: -3px; bottom: 11px; }

.week { height: 1px; background: var(--cut); }
.wd { font-weight: 600; color: var(--muted); }
.wd.we { color: var(--accent); }
.place, .end { color: var(--muted); }
.time, .start, .num { font-variant-numeric: tabular-nums; }

/* List: date – name/place – time */
.list .month { display: flex; flex-direction: column; gap: 16px; padding-bottom: 16px; }
.list .week { margin: -14px 0 0; }
.list .day { display: flex; align-items: baseline; gap: 14px; }
.list .date { display: flex; flex-direction: column; width: 76px; flex-shrink: 0; }
.list .num { font: 700 26px/1 var(--display); }
.list .date .wd { font-size: 13px; margin-top: 5px; white-space: nowrap; }
.list .events { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; padding-bottom: 8px; }
.list .day.rule .events { border-bottom: 1px solid var(--line); }
.list .ev {
    display: flex; justify-content: space-between; gap: 12px; min-height: 48px; padding: 2px 0 6px;
    text-decoration: none;
}
.list .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list .name { font-size: 17px; font-weight: 600; }
.list .place { font-size: 14px; }
.list .time { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.list .start { font-size: 15px; font-weight: 600; }
.list .end { font-size: 13px; }

/* Compact: one row per event */
.compact .week { margin-top: 4px; }
.compact .day.rule { border-bottom: 1px solid var(--line); }
.compact .row {
    display: flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none;
}
.compact .day > .row:not(:only-child):first-child { align-items: flex-end; min-height: 40px; padding-bottom: 3px; }
.compact .day > .row:not(:first-child):not(:last-child) { min-height: 24px; }
.compact .day > .row:not(:only-child):last-child { align-items: flex-start; min-height: 40px; padding-top: 3px; }
/* Weekday and day only ("Sa 9."): the month is in the sticky heading */
.compact .when { display: flex; justify-content: space-between; width: 46px; flex-shrink: 0; }
.compact .what { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compact .start { flex-shrink: 0; min-width: 40px; text-align: right; font-weight: 600; }

.empty { color: var(--muted); padding: 24px 0; }

.foot {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    margin-top: 32px; font-size: 14px; color: var(--muted);
}
.foot nav { display: flex; flex-wrap: wrap; gap: 4px; }
.foot > form, .foot > a { margin-left: auto; } /* Anmelden / Abmelden stay at the right, also without the season links */
.foot a, .link {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px;
    background: none; border: none; color: var(--muted); text-decoration: none; cursor: pointer;
}
.foot a[aria-current] { color: var(--text); font-weight: 600; }

/* Forms */
.bar { padding: 12px 12px 4px 6px; }
.back {
    display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 10px;
    font-size: 16px; text-decoration: none;
}
.narrow { padding: 8px 20px 40px; }
.narrow h1 { margin: 0 0 20px; font: 700 26px/1.15 var(--display); letter-spacing: -0.02em; }
.form { display: flex; flex-direction: column; }
.form label { margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form input {
    width: 100%; min-height: 48px; padding: 0 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
    font: inherit; font-size: 16px;
}
.form input:focus { outline: 2px solid var(--text); outline-offset: 1px; }
/* Date and time inputs have an intrinsic min width (iOS Safari: wider once a value is set); only without the native
   appearance does min-width: 0 take effect. Then iOS puts the value at the top of the box: the vertical padding
   centres it (13 + 20 + 13 + 2 border = 48px). */
.form input[type="date"], .form input[type="time"] {
    display: block; min-width: 0; -webkit-appearance: none; appearance: none; padding-block: 13px; line-height: 20px;
}
.form input::-webkit-date-and-time-value { text-align: left; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pair label { display: block; }
.error { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: var(--accent); }
.error:empty { display: none; }
.hint { margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.primary {
    min-height: 48px; margin-top: 24px;
    background: var(--text); color: var(--bg);
    border: none; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* Login */
.login {
    display: flex; flex-direction: column; align-items: center; gap: 20px;
    padding: 12px 20px 40px; /* below the 60px back bar */
}
.login-icon { border-radius: 21px; }
.login .wordmark { font-size: 32px; }
.login .brand { align-items: center; gap: 6px; }
.login .subtitle { font-size: 15px; }
.login .form { width: 100%; max-width: 340px; }

/* Event detail */
.bar.split { display: flex; justify-content: space-between; align-items: center; padding-right: 12px; }
.detail { display: flex; flex-direction: column; gap: 26px; }
.detail .head { display: flex; flex-direction: column; gap: 8px; }
.detail .head .wd { font-size: 14px; }
.detail h1 { margin: 0; }
.detail .range { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail .range .place { font-weight: 400; }
.detail dl { margin: 0; border-top: 1px solid var(--line); }
.detail dl > div {
    display: flex; justify-content: space-between; gap: 16px; padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.detail dt { color: var(--muted); }
.detail dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.detail dd a { text-underline-offset: 3px; }
.buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
.button {
    display: flex; align-items: center; justify-content: center; min-height: 48px; margin: 0;
    border-radius: 12px; font-size: 15px; font-weight: 600; text-decoration: none;
}
.button.secondary { border: 1px solid var(--border); }
