/* Legacy design tokens (build plan section 1.4). Components use these variables only - never a raw colour. */

@font-face {
    font-family: "Cinzel";
    src: url("../fonts/Cinzel.ttf") format("truetype");
    font-weight: 400 900;
    font-display: swap;
}

:root {
    color-scheme: light dark;

    --navy: #1C3A4F;
    --teal: #2A7F7A;
    --teal-deep: #1F5F5B;
    --gold: #C9A14A;
    --gold-deep: #A8842F;
    --leaf: #4E8A4A;
    --leaf-light: #7FA33A;
    --cream: #FBF8F2;
    --ink: #0F2230;

    --bg: var(--cream);
    --surface: #FFFFFF;
    --text: var(--navy);
    --text-muted: #5A6B78;
    --border: #E6DFD2;
    /* Contrast (WCAG AA, checked by ThemeContrastTests): the brand teal a shade deeper for text and links on cream
       (4.7:1), and the deeper gold for symbols like the favorite star (3.3:1). */
    --primary: #287B76;
    --primary-hover: var(--teal-deep);
    --on-primary: #FFFFFF;
    --accent: var(--gold-deep);
    --success: var(--leaf);
    --danger: #B3261E;
    --on-danger: #FFFFFF;
    --nav-bg: var(--navy);
    --nav-text: #DCE6EC;
    --nav-active: var(--gold);
    --mark-backdrop: transparent;

    --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Someone's own words: a reading serif in italics. (Cinzel is capitals only - right for headings, not for a sentence.) */
    --font-quote: Georgia, "Noto Serif", "Times New Roman", serif;

    --radius: 12px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 40px;
    --header-height: 56px;
    --bottom-nav-height: 64px;
    --sidebar-width: 232px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--ink);
        --surface: #16304A;
        --text: #EEF2F4;
        --text-muted: #9FB2BF;
        --border: #24425A;
        --primary: #48ACA6;
        --primary-hover: #5EBDB7;
        --on-primary: var(--ink);
        --accent: var(--gold);
        --danger: #F28B82;
        --on-danger: var(--ink);
        --nav-bg: #0A1A26;
        --nav-text: #C7D4DC;
        --mark-backdrop: var(--cream);
    }
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text);
    margin: 0 0 var(--space-3);
}

h1 { font-size: 1.75rem; }
h1:focus { outline: none; }

/* Keyboard and switch users always see where they are; a tap or click shows nothing. */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible { outline-offset: 3px; }

/* Asked for less motion: no slides, fades or smooth scrolling. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-4);
    border: 0;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--on-primary);
    font: 600 1rem var(--font-body);
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--primary-hover); color: var(--on-primary); }

.empty-state {
    max-width: 32rem;
    margin: var(--space-5) auto;
    padding: var(--space-4);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.empty-state img {
    width: 96px;
    height: 96px;
    margin-bottom: var(--space-3);
    padding: 6px;
    border-radius: 50%;
    background: var(--mark-backdrop);
}
.empty-state p { color: var(--text-muted); margin: 0 0 var(--space-3); }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); }

.blazor-error-boundary {
    padding: var(--space-3);
    background: var(--danger);
    color: var(--on-danger);
    border-radius: var(--radius);
}
.blazor-error-boundary::after { content: "Something went wrong."; }

/* Buttons beyond the primary */
.btn-secondary { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-secondary:hover { background: transparent; color: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger); color: var(--on-danger); filter: brightness(1.1); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Page header: title and its main action on one line */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.page-head h1 { margin: 0; }

/* Forms. Inputs are 16px so phones don't zoom in on focus. */
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-3); }
.field label { font-weight: 600; color: var(--text); }
.field .hint { font-size: 0.875rem; color: var(--text-muted); }
.field input[type=text], .field input[type=search], .field input[type=date], .field input[type=email], .field input[type=tel], .field input[type=password], .field input[type=number], .field textarea, .field select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: 16px var(--font-body);
}
.field textarea { min-height: 96px; resize: vertical; }
.field .relationship-other { margin-top: var(--space-1); }

/* Something under way (a button's work): a small ring turning, in the button's own colour. Still, for reduced motion. */
.spinner { display: inline-block; width: 1em; height: 1em; margin-right: 0.4em; vertical-align: -0.15em; border: 2px solid currentColor;
    border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-right-color: currentColor; opacity: 0.6; } }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.field-pair { display: grid; grid-template-columns: 1fr; gap: 0 var(--space-3); }
@media (min-width: 560px) { .field-pair { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; margin-bottom: var(--space-3); }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.form-error { padding: var(--space-3); margin-bottom: var(--space-3); border-radius: 8px; background: var(--surface); border: 1px solid var(--danger); color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.muted { color: var(--text-muted); }

/* A form brought up whole while the keyboard is up (keyboard.js) stops just under the sticky header. */
.keep-in-view { scroll-margin-top: calc(var(--header-height) + env(safe-area-inset-top) + var(--space-2)); }
/* While typing in one, a screen's own Save bar steps aside too: it's for the screen, not this form, and the room is short. */
html.keyboard-open body:has(.keep-in-view:focus-within) .save-bar { display: none; }

/* Printing a book (Phase 5): a copy of it is put at the top of the page (legacyBook.prepare) and only that prints. */
#print-root { display: none; }

@media print {
    html.printing-book body > *:not(#print-root) { display: none !important; }
    html.printing-book #print-root { display: block; }
    html.printing-book, html.printing-book body { background: #ffffff !important; }
}
