/* ---------- Design tokens ---------- */
:root {
    --bg: #f7f5f1;
    --bg-elevated: #ffffff;
    --bg-sunken: #efebe3;
    --text: #201c17;
    --text-muted: #6b6259;
    --border: #e2ddd2;
    --accent: #c2410c;
    --accent-strong: #9a3412;
    --accent-contrast: #fff8f2;
    --level-low: #b45309;
    --level-ideal: #15803d;
    --level-high: #b91c1c;
    --shadow: 0 1px 2px rgba(32, 22, 12, 0.06), 0 8px 24px rgba(32, 22, 12, 0.08);
    --radius-sm: 8px;
    --radius: 13px;
    --radius-lg: 18px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", serif;
    --rule: repeating-linear-gradient(to right, var(--border) 0, var(--border) 4px, transparent 4px, transparent 9px);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #14110d;
    --bg-elevated: #1c1712;
    --bg-sunken: #0d0b09;
    --text: #f4efe6;
    --text-muted: #a89985;
    --border: #332a20;
    --accent: #f2793d;
    --accent-strong: #ffab6b;
    --accent-contrast: #1a1108;
    --level-low: #f5c14a;
    --level-ideal: #4ade80;
    --level-high: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 28px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

/* ---------- MudBlazor palette bridge ----------
   MudThemeProvider writes its own literal --mud-palette-* values into a <style> tag; these
   !important overrides make MudBlazor's colors follow the site's own design tokens above instead,
   so Mud components (MudAppBar, MudIconButton, ...) pick up light/dark instantly via the same
   `data-theme` attribute the rest of the site already uses — no extra JS/state sync needed. */
:root {
    --mud-palette-primary: var(--accent) !important;
    --mud-palette-primary-darken: var(--accent-strong) !important;
    --mud-palette-primary-lighten: var(--accent-strong) !important;
    --mud-palette-primary-hover: color-mix(in srgb, var(--accent) 8%, transparent) !important;
    --mud-palette-primary-text: var(--accent-contrast) !important;
    --mud-palette-appbar-background: var(--bg-elevated) !important;
    --mud-palette-appbar-text: var(--text) !important;
    --mud-palette-background: var(--bg) !important;
    --mud-palette-background-gray: var(--bg-sunken) !important;
    --mud-palette-surface: var(--bg-elevated) !important;
    --mud-palette-text-primary: var(--text) !important;
    --mud-palette-text-secondary: var(--text-muted) !important;
    --mud-palette-text-disabled: var(--text-muted) !important;
    --mud-palette-action-default: var(--text-muted) !important;
    --mud-palette-action-default-hover: color-mix(in srgb, var(--text-muted) 8%, transparent) !important;
    --mud-palette-action-disabled: var(--text-muted) !important;
    --mud-palette-divider: var(--border) !important;
    --mud-palette-divider-light: var(--border) !important;
    --mud-palette-lines-default: var(--border) !important;
    --mud-palette-lines-inputs: var(--border) !important;
    --mud-palette-success: var(--level-ideal) !important;
    --mud-palette-success-hover: color-mix(in srgb, var(--level-ideal) 14%, transparent) !important;
    --mud-palette-error: var(--level-high) !important;
    --mud-palette-error-hover: color-mix(in srgb, var(--level-high) 14%, transparent) !important;
}

/* ---------- Layout shell (MudAppBar/MudMainContent are child-component roots, not literal
   elements in MainLayout.razor, so Blazor's CSS isolation can't scope-match them there — plain
   global rules instead, same as .icon-btn below) ---------- */
.site-appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 0 -3px var(--bg-elevated), 0 5px 0 -3px var(--border);
    height: auto;
}

/* MudAppBar's inner .mud-toolbar-appbar hardcodes a fixed height (--mud-appbar-height, ~56px)
   sized for its single-row desktop layout. When the header's own content wraps onto multiple
   rows on narrow screens, that fixed height clips nothing (overflow is visible, not hidden) — the
   overflow just paints on top of whatever page content comes after it. Let it grow to fit instead. */
.site-appbar .mud-toolbar-appbar {
    height: auto !important;
    min-height: 56px;
}

.site-main {
    padding: 1.75rem 0 3rem;
}

/* ---------- Reset ---------- */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

h1, h2, h3, p {
    margin: 0;
}

h1, h2, h3 {
    font-weight: 800;
    letter-spacing: -0.015em;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    font-family: inherit;
}

.container {
    max-width: min(94vw, 1600px);
    margin: 0 auto;
    padding: 0 1.25rem;
}

h1:focus {
    outline: none;
}

/* An old-field-guide-style eyebrow label: a small numbered/lettered tag plus a hairline rule,
   standing in for the generic rounded "FEATURED" pill badge. */
.eyebrow {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.eyebrow::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rule);
}

/* ---------- Shared panel chrome ----------
   No box: sections are flat, edge-to-edge fills of color instead of bordered/
   shadowed/rounded cards — the color block itself (plus the gap around it) is what
   separates one section from the next, no divider line needed. Secondary/
   supplementary columns (comments, builder live-preview, play-page step list) use
   a different flat tone — see .comments-panel below and each page's
   .panel-card/.step-list-panel — so primary vs. secondary content stays legible. */
.panel {
    background: var(--bg-elevated);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
}

.icon-btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
}

.icon-btn-sm:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Header toggles (theme / language islands) ---------- */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.lang-menu .mud-icon-button-size-small {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
}

.lang-menu .mud-icon-button-size-small:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Label-less filled/outlined Mud inputs (search boxes, method filters) reserve vertical space for
   a floating label that doesn't exist here, sinking the placeholder/text toward the bottom.
   MudBlazor has its own "hidden-label" padding for exactly this case (10px/11px) — apply it
   directly since these fields only ever use Placeholder, never Label. */
.search-field .mud-input-root-filled.mud-input-root-margin-dense,
.method-select .mud-input-root-filled.mud-input-root-margin-dense {
    padding-top: 10px !important;
    padding-bottom: 11px !important;
}

/* The adornment icon carries a 16px top margin meant to clear a floating label — these fields
   never have one, so it just pushes the icon off-center. Let flexbox centering do its job. */
.search-field .mud-input-adornment,
.method-select .mud-input-adornment {
    margin-top: 0 !important;
}

/* ---------- Shared primary action button (page-header "+ New X" CTAs, publish, play, etc.) ---------- */
.title-action-btn {
    border-radius: var(--radius-sm) !important;
    font-weight: 700;
    white-space: nowrap;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.title-action-btn:not(.mud-disabled):hover {
    transform: translateY(-1px);
}

/* ---------- Comments (shared across water/grind/recipe detail pages) ----------
   The secondary column next to the main content — a different flat tone from the
   primary .panel fill, so the two stay visually distinct without a boxed card. */
.comments-panel {
    gap: 1rem;
    background: var(--bg-sunken);
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: flex-end;
}

.comment-form .mud-input-filled {
    width: 100%;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-sunken) 65%, var(--bg-elevated) 35%);
    border: 1px solid var(--border);
}

.comment-login-hint {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.load-more-row {
    display: flex;
    justify-content: center;
    padding-top: 0.85rem;
}

.no-comments {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.comment-row {
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.comment-row:first-child {
    padding-top: 0;
    border-top: none;
}

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.comment-author {
    font-weight: 700;
    font-size: 0.88rem;
}

.comment-delete-btn {
    margin-left: auto;
    color: var(--text-muted);
    padding: 0.2rem;
}

.comment-delete-btn:hover {
    color: var(--level-high);
}

.comment-time {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.comment-body {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.comment-pagination {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
}

.user-name-tag {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
}

.user-handle {
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Owner-only "Edit" entry point (water/grind/recipe detail headers) ---------- */
.edit-entry-link {
    font-size: 0.82rem;
    margin-left: auto;
}

/* ---------- Shared hover tooltip ("i" info icon next to a field/label) ---------- */
.tip {
    position: relative;
    display: inline-flex;
}

.tip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-style: italic;
    cursor: help;
}

.tip-box {
    position: absolute;
    left: 0;
    top: 130%;
    z-index: 5;
    width: 230px;
    background: var(--text);
    color: var(--bg);
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.35;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.tip:hover .tip-box,
.tip:focus-within .tip-box {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ---------- Shared form / auth chrome ---------- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.65rem 1.1rem;
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.auth-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 2px 4px rgba(40, 26, 12, 0.05), 0 20px 48px rgba(40, 26, 12, 0.12);
    padding: 2.75rem 2.5rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

:root[data-theme="dark"] .auth-card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 20px 48px rgba(0, 0, 0, 0.45);
}

.auth-card > h1 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    margin-top: -1.1rem;
}

.auth-card form,
.edit-profile-panel form {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.auth-card .field,
.edit-profile-panel form .field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-card .field label,
.edit-profile-panel form .field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card .password-field input,
.edit-profile-panel form .password-field input {
    appearance: none;
    -webkit-appearance: none;
    border: 1.5px solid transparent;
    background: var(--bg-sunken);
    color: var(--text);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    line-height: 1.3;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.auth-card input[type="text"]::placeholder,
.auth-card input[type="email"]::placeholder,
.auth-card .password-field input::placeholder,
.edit-profile-panel form .password-field input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.auth-card input[type="text"]:hover,
.auth-card input[type="email"]:hover,
.auth-card .password-field input:hover,
.edit-profile-panel form .password-field input:hover {
    background: color-mix(in srgb, var(--bg-sunken) 70%, var(--border));
}

.auth-card input[type="text"]:focus,
.auth-card input[type="email"]:focus,
.auth-card .password-field input:focus,
.edit-profile-panel form .password-field input:focus {
    outline: none;
    background: var(--bg);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.password-field {
    position: relative;
    display: flex;
}

.password-field input {
    flex: 1;
    padding-right: 2.6rem;
}

.password-toggle {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.password-toggle:hover {
    color: var(--accent);
}

.auth-card .btn-primary {
    width: 100%;
    padding: 0.85rem 1.1rem;
    font-size: 1rem;
    border-radius: 12px;
    margin-top: 0.35rem;
    box-shadow: 0 1px 2px rgba(40, 26, 12, 0.08);
}

.remember-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.remember-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.forgot-password-link {
    color: var(--accent);
    font-weight: 600;
}

.auth-error {
    background: color-mix(in srgb, var(--level-high) 14%, transparent);
    color: var(--level-high);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-size: 0.86rem;
    font-weight: 600;
}

.field-error {
    color: var(--level-high);
    font-size: 0.78rem;
    font-weight: 600;
}

.password-requirements {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0.15rem 0 0;
    padding: 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.password-requirements .req-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    color: var(--accent-contrast);
    flex-shrink: 0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.password-requirements li.met {
    color: var(--level-ideal);
}

.password-requirements li.met .req-icon {
    background: var(--level-ideal);
    border-color: var(--level-ideal);
}

.auth-switch {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- Framework chrome ---------- */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }
