/* =====================================================================
   FamilyManager – Design-System „Wochenmarkt"
   Leitmotiv: der Teller (Gerichte als runde Draufsicht).
   ===================================================================== */

@font-face {
    font-family: "Bricolage Grotesque";
    src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
    font-weight: 200 800;
    font-stretch: 75% 100%;
    font-display: swap;
}

@font-face {
    font-family: "Figtree";
    src: url("../fonts/figtree.woff2") format("woff2");
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Figtree";
    src: url("../fonts/figtree-italic.woff2") format("woff2");
    font-weight: 300 900;
    font-style: italic;
    font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;

    /* Grundpalette */
    --kalk: #F5F6F1;          /* Hintergrund: kühles Kalkweiß, leicht grünstichig */
    --surface: #FFFFFF;
    --surface-sunk: #ECEEE6;
    --aubergine: #2A1B30;     /* Schrift */
    --ink-soft: #66586C;
    --ink-faint: #9A8FA0;
    --line: #DCDDD3;
    --basil: #2E7D4F;         /* Aktionen */
    --basil-deep: #1F5E3A;
    --basil-tint: #DCEFE2;
    --saffron: #F0B429;       /* eingekauft / gesperrt */
    --saffron-tint: #FCEFC9;
    --radicchio: #A8325A;     /* Bewertungen, Warnungen */
    --radicchio-tint: #F6DDE5;
    --on-basil: #FFFFFF;

    /* Avatar-Farben */
    --m-basil: #2E7D4F;
    --m-saffron: #D99A0E;
    --m-radicchio: #A8325A;
    --m-plum: #6D4C9F;
    --m-sky: #2F6F96;
    --m-carrot: #D2652A;

    /* Teller */
    --plate-rim: #FFFFFF;
    --plate-well: #F0F1EB;
    --plate-shadow: 0 1px 0 rgba(42, 27, 48, .06), 0 10px 30px -12px rgba(42, 27, 48, .28);

    /* Typografie */
    --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
    --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    --step--1: .833rem;
    --step-0: 1.0625rem;
    --step-1: 1.25rem;
    --step-2: 1.563rem;
    --step-3: 1.953rem;
    --step-4: 2.6rem;
    --step-5: 3.4rem;

    /* Raum & Form */
    --gutter: 1rem;
    --content: 40rem;
    --radius-s: 10px;
    --radius-m: 18px;
    --radius-sheet: 28px;
    --nav-height: 4.25rem;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);

    /* Bewegung */
    --spring: cubic-bezier(.34, 1.4, .64, 1);
    --ease-out: cubic-bezier(.22, 1, .36, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --kalk: #17101B;
        --surface: #231A28;
        --surface-sunk: #1D1522;
        --aubergine: #F3EEF5;
        --ink-soft: #BFB3C6;
        --ink-faint: #8C7F93;
        --line: #3A2F40;
        --basil: #5DBB83;
        --basil-deep: #7FD09F;
        --basil-tint: #1F3A2B;
        --saffron: #F5C451;
        --saffron-tint: #3D3218;
        --radicchio: #E0708F;
        --radicchio-tint: #43202C;
        --on-basil: #0E2416;
        --plate-rim: #2E2434;
        --plate-well: #261D2B;
        --plate-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 30px -12px rgba(0, 0, 0, .7);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --kalk: #17101B;
    --surface: #231A28;
    --surface-sunk: #1D1522;
    --aubergine: #F3EEF5;
    --ink-soft: #BFB3C6;
    --ink-faint: #8C7F93;
    --line: #3A2F40;
    --basil: #5DBB83;
    --basil-deep: #7FD09F;
    --basil-tint: #1F3A2B;
    --saffron: #F5C451;
    --saffron-tint: #3D3218;
    --radicchio: #E0708F;
    --radicchio-tint: #43202C;
    --on-basil: #0E2416;
    --plate-rim: #2E2434;
    --plate-well: #261D2B;
    --plate-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 30px -12px rgba(0, 0, 0, .7);
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--kalk);
    color: var(--aubergine);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.5;
    font-feature-settings: "ss01";
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.015em;
    margin: 0;
    text-wrap: balance;
}

h1 { font-size: var(--step-4); font-stretch: 80%; font-weight: 800; }
h2 { font-size: var(--step-2); font-stretch: 90%; }
h3 { font-size: var(--step-1); }
p { margin: 0; text-wrap: pretty; max-width: 62ch; }
a { color: var(--basil-deep); text-underline-offset: .18em; }
h1:focus { outline: none; }

:focus-visible {
    outline: 3px solid var(--basil);
    outline-offset: 3px;
    border-radius: 6px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.muted { color: var(--ink-soft); }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, 1rem); }
.row { display: flex; align-items: center; gap: .75rem; }

/* ---------- Boot-Bildschirm (vor Blazor) ---------- */
.boot {
    min-height: 100dvh;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1.25rem;
}

.boot-plate { width: 7.5rem; height: 7.5rem; }
.boot-rim { fill: var(--plate-rim); filter: drop-shadow(0 8px 16px rgba(42, 27, 48, .18)); }
.boot-well { fill: var(--plate-well); }

.boot-progress {
    fill: none;
    stroke: var(--basil);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 18 82;
    transform-origin: center;
    animation: spin 1.4s linear infinite;
}

.boot-text { color: var(--ink-soft); font-size: var(--step--1); }

/* ---------- App-Rahmen ---------- */
.shell {
    min-height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 1.5rem);
}

.topbar {
    max-width: var(--content);
    margin: 0 auto;
    padding: .9rem var(--gutter) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-date {
    font-size: var(--step--1);
    color: var(--ink-soft);
    font-weight: 600;
}

.page {
    max-width: var(--content);
    margin: 0 auto;
    padding: 1.25rem var(--gutter) 0;
}

/* Nur während eines Seitenwechsels: view-transition-name erzeugt eine eigene
   Ebene und würde sonst Bottom-Sheets unter die Navigation drücken. */
:root[data-nav-direction] .page { view-transition-name: page; }

/* ---------- Untere Navigation ---------- */
.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    padding: .5rem var(--gutter) calc(.5rem + var(--safe-bottom));
    background: color-mix(in srgb, var(--kalk) 82%, transparent);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

:root[data-nav-direction] .tabbar { view-transition-name: tabbar; }

.tabbar-inner {
    position: relative;
    max-width: 28rem;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--nav-height) - 1rem);
}

.tabbar-indicator {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: 25%;
    padding: 0 .35rem;
    transform: translateX(calc(var(--tab-index, 0) * 100%));
    transition: transform .45s var(--spring), opacity .2s;
    pointer-events: none;
}

.tabbar-indicator::before {
    content: "";
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--basil-tint);
}

.tabbar-inner[data-active="-1"] .tabbar-indicator { opacity: 0; }

.tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .1rem;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 999px;
    transition: color .2s;
}

.tab svg { width: 1.6rem; height: 1.6rem; transition: transform .35s var(--spring); }
.tab.active { color: var(--basil-deep); }
.tab.active svg { transform: translateY(-1px) scale(1.06); }
.tab:active svg { transform: scale(.9); }

/* ---------- Avatare ---------- */
.avatar {
    --c: var(--m-basil);
    display: inline-grid;
    place-items: center;
    width: var(--size, 2.25rem);
    height: var(--size, 2.25rem);
    border-radius: 50%;
    background: var(--c);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: calc(var(--size, 2.25rem) * .42);
    flex: none;
    user-select: none;
}

.avatar[data-color="basil"] { --c: var(--m-basil); }
.avatar[data-color="saffron"] { --c: var(--m-saffron); }
.avatar[data-color="radicchio"] { --c: var(--m-radicchio); }
.avatar[data-color="plum"] { --c: var(--m-plum); }
.avatar[data-color="sky"] { --c: var(--m-sky); }
.avatar[data-color="carrot"] { --c: var(--m-carrot); }

.avatar-stack {
    display: flex;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    border-radius: 999px;
    text-decoration: none;
}

.avatar-stack .avatar {
    --size: 2rem;
    box-shadow: 0 0 0 2px var(--kalk);
}

.avatar-stack .avatar + .avatar { margin-left: -.55rem; }

/* ---------- Buttons ---------- */
.btn {
    --bg: var(--basil);
    --fg: var(--on-basil);
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 3.25rem;
    padding: 0 1.5rem;
    border: 0;
    border-radius: 999px;
    background: var(--bg);
    color: var(--fg);
    font: 700 var(--step-0)/1 var(--font-body);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .25s var(--spring), background-color .2s, box-shadow .2s;
    box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--bg) 80%, transparent);
}

.btn:hover { background: color-mix(in srgb, var(--bg) 88%, black); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn svg { width: 1.25rem; height: 1.25rem; }
.btn-block { width: 100%; }

.btn-quiet {
    --bg: transparent;
    --fg: var(--basil-deep);
    box-shadow: none;
    padding: 0 1rem;
}

.btn-quiet:hover { background: var(--basil-tint); }

.btn-ghost {
    --bg: var(--surface);
    --fg: var(--aubergine);
    box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-ghost:hover { background: var(--surface-sunk); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}

.icon-btn:hover { background: var(--surface-sunk); color: var(--aubergine); }
.icon-btn svg { width: 1.35rem; height: 1.35rem; }

.btn .spinner {
    width: 1.1rem; height: 1.1rem;
    border-radius: 50%;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-weight: 600; font-size: var(--step--1); color: var(--ink-soft); }

.input {
    width: 100%;
    min-height: 3.25rem;
    padding: 0 1rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-m);
    background: var(--surface);
    color: var(--aubergine);
    font: 500 var(--step-0)/1.2 var(--font-body);
    transition: border-color .15s, box-shadow .15s;
}

.input::placeholder { color: var(--ink-faint); }

.input:focus {
    outline: none;
    border-color: var(--basil);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--basil) 18%, transparent);
}

.form-error {
    padding: .85rem 1rem;
    border-radius: var(--radius-m);
    background: var(--radicchio-tint);
    color: var(--radicchio);
    font-weight: 600;
    font-size: var(--step--1);
}

/* Segmentschalter (z. B. Anmelden / Konto erstellen) */
.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: .25rem;
    border-radius: 999px;
    background: var(--surface-sunk);
}

.segmented button {
    min-height: 2.6rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font: 700 var(--step--1)/1 var(--font-body);
    cursor: pointer;
    transition: background-color .25s var(--ease-out), color .2s;
}

.segmented button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--aubergine);
    box-shadow: 0 2px 8px -3px rgba(42, 27, 48, .25);
}

/* Farbwahl für Avatare */
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }

.swatch {
    width: 2.25rem; height: 2.25rem;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: var(--c);
    box-shadow: 0 0 0 0 var(--kalk), 0 0 0 0 var(--c);
    transition: box-shadow .2s var(--ease-out), transform .25s var(--spring);
}

.swatch[aria-checked="true"] {
    box-shadow: 0 0 0 3px var(--kalk), 0 0 0 5px var(--c);
    transform: scale(1.05);
}

/* ---------- Teller ---------- */
.plate {
    position: relative;
    width: var(--plate-size, 14rem);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--plate-rim);
    box-shadow: var(--plate-shadow);
    display: grid;
    place-items: center;
    flex: none;
}

.plate::before {
    content: "";
    position: absolute;
    inset: 14%;
    border-radius: 50%;
    background: var(--plate-well);
    box-shadow: inset 0 2px 6px rgba(42, 27, 48, .08);
}

.plate > * { position: relative; }

.plate-empty-mark {
    width: 34%;
    color: var(--ink-faint);
    opacity: .7;
}

/* Der eine orchestrierte Moment: Teller wird auf den Tisch gestellt */
.plate-arrive {
    animation: plate-arrive .9s var(--ease-out) both;
}

@keyframes plate-arrive {
    from { opacity: 0; transform: translateY(-1.5rem) scale(.92) rotate(-14deg); }
    60% { opacity: 1; }
    to { opacity: 1; transform: none; }
}

/* Besteck links & rechts vom Teller */
.place-setting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
}

.cutlery { width: 1.1rem; height: 9rem; color: var(--ink-faint); opacity: .55; }

/* ---------- Bereiche ---------- */
.hero-today { display: flex; flex-direction: column; gap: 1.75rem; padding-top: .5rem; }
.hero-today h1 { font-size: var(--step-5); }

.empty {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

.empty .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

.page-head { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.75rem; }

/* Woche: Vorschau als Tellerreihe */
.week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: .4rem;
    margin: .5rem 0 1.5rem;
}

.week-day { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.week-day span { font-size: .75rem; font-weight: 700; color: var(--ink-soft); }
.week-day.today span { color: var(--basil-deep); }

.week-day .mini-plate {
    width: 100%;
    max-width: 3rem;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px dashed var(--line);
}

.week-day.today .mini-plate { border-color: var(--basil); border-style: solid; background: var(--basil-tint); }

/* Listen */
.list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border-radius: var(--radius-m);
    box-shadow: inset 0 0 0 1px var(--line);
}

.list > li {
    display: flex;
    align-items: center;
    gap: .9rem;
    min-height: 4rem;
    padding: .6rem .75rem .6rem 1rem;
}

.list > li + li { border-top: 1px solid var(--line); }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 700; }
.list .meta { font-size: var(--step--1); color: var(--ink-soft); }

.section-title {
    font-family: var(--font-body);
    font-size: var(--step--1);
    font-weight: 700;
    color: var(--ink-soft);
    margin: 2rem 0 .6rem .25rem;
}

/* Bottom-Sheet / Bearbeiten */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(23, 16, 27, .38);
    animation: fade-in .2s ease-out;
}

.sheet {
    position: fixed;
    z-index: 41;
    left: 50%;
    bottom: 0;
    width: min(100%, 34rem);
    transform: translateX(-50%);
    padding: 1.25rem var(--gutter) calc(1.25rem + var(--safe-bottom));
    background: var(--kalk);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    animation: sheet-up .45s var(--ease-out);
}

.sheet::before {
    content: "";
    display: block;
    width: 2.5rem; height: .3rem;
    margin: -.4rem auto 1rem;
    border-radius: 999px;
    background: var(--line);
}

@keyframes sheet-up { from { transform: translate(-50%, 100%); } }
@keyframes fade-in { from { opacity: 0; } }

/* Willkommen & Einrichtung (ohne Navigation) */
.bare {
    min-height: 100dvh;
    max-width: 30rem;
    margin: 0 auto;
    padding: calc(2rem + var(--safe-top)) var(--gutter) calc(2rem + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.welcome-hero { display: flex; flex-direction: column; gap: 1.5rem; }
.welcome-hero h1 { font-size: clamp(2.4rem, 11vw, var(--step-5)); }

.steps {
    display: flex;
    gap: .4rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.steps li {
    height: .3rem;
    flex: 1;
    border-radius: 999px;
    background: var(--line);
    transition: background-color .4s var(--ease-out);
}

.steps li.done { background: var(--basil); }

.member-draft {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 1rem;
    border-radius: var(--radius-m);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line);
    animation: pop-in .35s var(--spring);
}

@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }

/* ---------- Seitenübergänge ---------- */
::view-transition-old(page) { animation: vt-out .18s ease-in both; }
::view-transition-new(page) { animation: vt-in .32s var(--ease-out) both; }

:root[data-nav-direction="forward"]::view-transition-old(page) { animation-name: vt-out-left; }
:root[data-nav-direction="forward"]::view-transition-new(page) { animation-name: vt-in-right; }
:root[data-nav-direction="back"]::view-transition-old(page) { animation-name: vt-out-right; }
:root[data-nav-direction="back"]::view-transition-new(page) { animation-name: vt-in-left; }

@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(.5rem); } }
@keyframes vt-out-left { to { opacity: 0; transform: translateX(-1.5rem); } }
@keyframes vt-in-right { from { opacity: 0; transform: translateX(1.5rem); } }
@keyframes vt-out-right { to { opacity: 0; transform: translateX(1.5rem); } }
@keyframes vt-in-left { from { opacity: 0; transform: translateX(-1.5rem); } }

/* ---------- Fehlerleiste ---------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: var(--gutter);
    right: var(--gutter);
    bottom: calc(var(--nav-height) + var(--safe-bottom) + .75rem);
    z-index: 100;
    padding: 1rem 3rem 1rem 1rem;
    border-radius: var(--radius-m);
    background: var(--aubergine);
    color: var(--kalk);
    font-weight: 600;
}

#blazor-error-ui .reload { color: var(--saffron); margin-left: .5rem; }

#blazor-error-ui .dismiss {
    position: absolute;
    right: .5rem;
    top: .5rem;
    border: 0;
    background: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- Größere Bildschirme ---------- */
@media (min-width: 48rem) {
    :root { --gutter: 2rem; }
    .hero-today { flex-direction: row-reverse; align-items: center; justify-content: space-between; }
}
