/* ============================================================
   nibabin — calm design system
   Light is default; [data-theme="dark"] flips the tokens.
   ============================================================ */

:root,
[data-theme="light"] {
    --bg: #f7f4ee;
    --bg-tint: #efece3;
    --surface: #fffdf9;
    --surface-2: #f4f1ea;
    --ink: #2a2723;
    --ink-soft: #514c44;
    --muted: #837c70;
    --border: #e6e0d4;
    --border-strong: #d7d0c1;
    --primary: #3f6f63;
    --primary-hover: #335a50;
    --primary-ink: #ffffff;
    --primary-soft: #e6efe9;
    --accent: #c08a4a;
    --danger: #a8443a;
    --danger-soft: #f6e7e4;
    --success: #3f6f63;
    --shadow: 0 1px 2px rgba(42, 39, 35, .04), 0 8px 24px rgba(42, 39, 35, .06);
    --shadow-sm: 0 1px 2px rgba(42, 39, 35, .06);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 999px;
}

[data-theme="dark"] {
    --bg: #1c1b19;
    --bg-tint: #232120;
    --surface: #26241f;
    --surface-2: #2f2c27;
    --ink: #f0ece4;
    --ink-soft: #d3cdc1;
    --muted: #a39c8e;
    --border: #3a3631;
    --border-strong: #4a453e;
    --primary: #7bb3a4;
    --primary-hover: #8cc2b3;
    --primary-ink: #15201c;
    --primary-soft: #2b3a35;
    --accent: #d6a468;
    --danger: #e08a80;
    --danger-soft: #3a2a28;
    --success: #7bb3a4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand__name {
    font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
    color: var(--ink);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* Headings receive programmatic focus on navigation (FocusOnNavigate) for
   screen readers — keep that, but don't draw a visible focus box on them. */
h1:focus, h2:focus, h3:focus,
h1:focus-visible, h2:focus-visible, h3:focus-visible { outline: none; }

p { color: var(--ink-soft); }

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.app-header__inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.brand { display: inline-flex; align-items: center; gap: .55rem; }
.brand:hover { text-decoration: none; }

.brand__mark { width: 30px; height: 30px; display: block; }

.brand__name { font-size: 1.4rem; color: var(--ink); }

.app-nav { display: flex; gap: .25rem; margin-left: .5rem; }

.app-nav__link {
    padding: .4rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    font-size: .95rem;
}
.app-nav__link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.app-nav__link.active { background: var(--primary-soft); color: var(--primary); }

.app-header__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.user-chip {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: .9rem;
}

.logout-form { margin: 0; }

.app-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3.5rem;
}

.app-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 1.25rem;
    font-size: .9rem;
}

/* ---------- Appearance toggle ---------- */
.theme-toggle {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 2px;
}
.theme-toggle__btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    width: 30px; height: 28px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle__btn:hover { color: var(--ink); }
html[data-theme-mode="light"] .theme-toggle__btn[data-mode="light"],
html[data-theme-mode="dark"] .theme-toggle__btn[data-mode="dark"],
html[data-theme-mode="system"] .theme-toggle__btn[data-mode="system"] {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ---------- Buttons (bespoke, nb- prefix to avoid Bootstrap clash) ---------- */
.nb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font: inherit;
    font-weight: 600;
    padding: .7rem 1.25rem;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .05s ease;
    text-decoration: none;
    line-height: 1.2;
}
.nb-btn:hover { text-decoration: none; }
.nb-btn:active { transform: translateY(1px); }
.nb-btn--sm { padding: .45rem .9rem; font-size: .9rem; }
.nb-btn--lg { padding: .85rem 1.6rem; font-size: 1.05rem; }
.nb-btn--primary { background: var(--primary); color: var(--primary-ink); }
.nb-btn--primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.nb-btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--border-strong); }
.nb-btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.nb-btn--block { width: 100%; }

/* ---------- Cards ---------- */
.card-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
}

.section-lead { color: var(--muted); max-width: 60ch; }

/* ---------- Household members / invites ---------- */
.member-list { list-style: none; padding: 0; margin: 0; }
.member-row, .invite-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}
.member-row:last-child, .invite-row:last-child { border-bottom: 0; }
.role-badge {
    font-size: .8rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-soft);
    padding: .25rem .6rem;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

/* ---------- Hero / landing ---------- */
.hero__eyebrow {
    color: var(--primary);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: .78rem;
}
.hero__lead { font-size: 1.18rem; color: var(--ink-soft); max-width: 46ch; }
.hero__actions { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-top: 2rem; }
.hero__signin { color: var(--muted); font-size: .95rem; }

.landing { position: relative; }

/* Warm "aurora" glow behind the hero — lively but soft. */
.landing__aurora {
    position: absolute;
    inset: -120px -40px auto -40px;
    height: 460px;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(closest-side at 18% 30%, color-mix(in srgb, var(--primary) 30%, transparent), transparent),
        radial-gradient(closest-side at 78% 18%, color-mix(in srgb, var(--accent) 34%, transparent), transparent),
        radial-gradient(closest-side at 55% 70%, color-mix(in srgb, var(--primary) 18%, transparent), transparent);
    filter: blur(28px);
    opacity: .8;
}

.landing__hero {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 2.5rem;
    align-items: center;
    padding: 1.5rem 0 1rem;
}
.landing__copy { max-width: 600px; }
.landing__title {
    font-size: clamp(2.4rem, 5vw, 3.7rem);
    line-height: 1.04;
    margin: .6rem 0 1.1rem;
}
.text-gradient {
    background: linear-gradient(105deg, var(--primary), var(--accent) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline;
}

/* Floating "memory cards" composition. */
.landing__visual {
    position: relative;
    min-height: 320px;
}
.memory-card {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 168px;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: nb-float 7s ease-in-out infinite;
}
.memory-card__icon { font-size: 1.6rem; }
.memory-card__label { font-weight: 600; color: var(--ink); font-size: .98rem; }
.memory-card--1 { top: 8%;  left: 4%;  transform: rotate(-5deg); animation-delay: 0s; }
.memory-card--2 { top: 0;   right: 6%; transform: rotate(4deg);  animation-delay: .8s; }
.memory-card--3 { bottom: 6%; left: 16%; transform: rotate(3deg); animation-delay: 1.6s; }
.memory-card--4 { bottom: 12%; right: 2%; transform: rotate(-3deg); animation-delay: 2.4s;
    border-color: var(--primary); box-shadow: 0 10px 30px color-mix(in srgb, var(--primary) 30%, transparent); }
.memory-card--4 .memory-card__label { color: var(--primary); }

@keyframes nb-float {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -10px; }
}

/* Feature row below the hero. */
.feature-row {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
    margin-top: 3rem;
}
.feature {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature h3 { margin: .9rem 0 .35rem; font-size: 1.2rem; }
.feature p { margin: 0; font-size: .96rem; }
.feature__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border-radius: 14px;
    font-size: 1.25rem;
    color: var(--primary-ink);
    background: linear-gradient(140deg, var(--primary), var(--primary-hover));
}
.feature__badge--share { background: linear-gradient(140deg, #c8607a, #a8443a); }
.feature__badge--keep { background: linear-gradient(140deg, var(--accent), #a06a2e); }

@media (prefers-reduced-motion: reduce) {
    .memory-card { animation: none; }
}

@media (max-width: 860px) {
    .landing__hero { grid-template-columns: 1fr; gap: 1rem; }
    .landing__visual { min-height: 280px; order: 2; margin-top: 1rem; }
    .feature-row { grid-template-columns: 1fr; }
    .landing__aurora { height: 360px; }
}

/* ---------- Dashboard ---------- */
.dash-greeting { font-size: 1.05rem; color: var(--muted); margin-bottom: .25rem; }
.empty-state {
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
}
.empty-state h2 { font-size: 1.65rem; margin: 0 0 .5rem; }
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 1.75rem; }
.suggestion-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.suggestion-card h3 { font-size: 1.15rem; margin: 0; }
.suggestion-card p { margin: 0; font-size: .95rem; flex: 1; }
.suggestion-card .nb-btn { align-self: flex-start; margin-top: .5rem; }

/* ---------- Auth (centred card) ---------- */
.auth-wrap {
    min-height: 60vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 1rem;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.auth-card h1 { font-size: 1.7rem; margin: 0 0 .25rem; }
.auth-card__lead { color: var(--muted); margin: 0 0 1.5rem; }
.auth-alt { margin-top: 1.5rem; text-align: center; color: var(--muted); font-size: .95rem; }
.auth-meta { margin-top: .75rem; text-align: center; font-size: .92rem; }

/* ---------- Bespoke form fields ---------- */
.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-weight: 500; font-size: .92rem; margin-bottom: .35rem; color: var(--ink-soft); }
.field-hint { color: var(--muted); font-size: .82rem; margin-top: .3rem; }
.field-input,
.field select {
    width: 100%;
    padding: .7rem .85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-tint);
    color: var(--ink);
    font: inherit;
}
.field-input:focus,
.field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    background: var(--surface);
}
.field-error { color: var(--danger); font-size: .85rem; margin-top: .3rem; display: block; }

.alert-note {
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: .92rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink-soft);
}
.alert-note--ok { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.alert-note--error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ============================================================
   Calm restyle of Bootstrap (used by secondary Identity pages)
   ============================================================ */
.btn { border-radius: var(--radius-pill); font-weight: 600; }
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-color: var(--primary-ink);
    --bs-btn-hover-color: var(--primary-ink);
}
.btn-link { --bs-btn-link-color: var(--primary); --bs-btn-link-hover-color: var(--primary-hover); }
.form-control, .form-select {
    background: var(--bg-tint);
    border-color: var(--border-strong);
    color: var(--ink);
    border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    color: var(--ink);
}
.form-floating > label { color: var(--muted); }
.form-label { color: var(--ink-soft); font-weight: 500; }
h1 { font-size: 1.9rem; }

/* Identity pages render bare under our shell; give them breathing room. */
.app-main > h1:first-child { margin-bottom: 1rem; }

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    color: var(--ink);
    background: var(--surface);
    border-top: 1px solid var(--border);
    bottom: 0;
    box-shadow: 0 -1px 8px rgba(0,0,0,.1);
    display: none;
    left: 0;
    padding: .8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }

.blazor-error-boundary {
    background: var(--danger-soft);
    padding: 1rem;
    border-radius: var(--radius-sm);
    color: var(--danger);
}

@media (max-width: 640px) {
    .app-header__inner { flex-wrap: wrap; gap: .75rem; padding: .6rem 1rem; }
    .app-nav { order: 3; width: 100%; }
    .user-chip { display: none; }
    .app-main { padding: 1.75rem 1rem 2.5rem; }
}
