/* =========================================================================
   Animus owner-side shared design tokens + base components
   Drop <link rel="stylesheet" href="owner-shared.css?v=1"> in any owner page.
   Bump ?v= when this file changes to bust mobile caches.
   ========================================================================= */

:root {
    /* Surfaces */
    --bg: #ECE8D2;
    --bg-soft: #f3eedb;
    --bg-deep: #e0d9bb;
    --card: #ead7bd;
    --surface-white: #ffffff;
    --white-soft: rgba(255, 255, 255, 0.7);
    --white-soft-2: rgba(255, 255, 255, 0.5);

    /* Text */
    --text: #111111;
    --muted: #5a4a3a;
    --muted-soft: #8a7d65;
    --muted-help: #666666;

    /* Brand */
    --orange: #ee7a1c;
    --orange-hover: #f48a30;
    --orange-soft: rgba(238, 122, 28, 0.12);

    /* Status */
    --danger: #d32f2f;
    --success: #2e7d32;

    /* Radii */
    --radius-card: 24px;
    --radius-input: 14px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-card: 0 10px 24px rgba(0, 0, 0, 0.05);
    --shadow-button: 0 8px 18px rgba(255, 122, 0, 0.22);
    --shadow-button-strong: 0 10px 24px rgba(255, 122, 0, 0.28);

    /* Type */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* =========================================================================
   Reset + body
   ========================================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
}

body.owner {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

/* =========================================================================
   Top navigation chrome is owned by menu.js (it injects sticky-nav styles
   alongside the menu popup). Pages just need to render:
   <nav class="animus-nav">
       <div class="animus-nav-left">
           <img id="nav-menu-icon" src="IconNevDay.png" class="animus-nav-icon">
           <p class="animus-nav-title">Page Title</p>
       </div>
       <div id="nav-close-btn" class="close-btn">&times;</div>  (optional)
   </nav>
   ========================================================================= */

/* =========================================================================
   Page container
   ========================================================================= */
.page {
    padding: 0 28px calc(40px + env(safe-area-inset-bottom));
    max-width: 600px;
    margin: 0 auto;
}

/* =========================================================================
   Cards / sections (beige surface)
   ========================================================================= */
.card,
.section {
    background: var(--card);
    border-radius: var(--radius-card);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}
.card h3,
.section h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
    font-weight: 800;
}
.card .helper,
.section .helper {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 16px;
    line-height: 1.4;
}

/* =========================================================================
   Inputs
   ========================================================================= */
.input {
    width: 100%;
    padding: 14px 18px;
    font-size: 16px;
    font-family: inherit;
    background: var(--white-soft);
    border: 2px solid transparent;
    border-radius: var(--radius-input);
    outline: none;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s;
}
.input:focus {
    border-color: var(--orange);
    background: var(--surface-white);
}
.input::placeholder { color: #9b9079; }

.input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.input-row .input { flex: 1; min-width: 0; }

.field-row {
    font-size: 16px;
    color: #333;
    padding: 14px 16px;
    background: var(--white-soft-2);
    border-radius: 12px;
    word-break: break-all;
}

/* =========================================================================
   Buttons
   ========================================================================= */
.btn-primary,
.save-btn {
    border: none;
    border-radius: var(--radius-pill);
    background: var(--orange);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 22px;
    cursor: pointer;
    box-shadow: var(--shadow-button);
    transition: transform 0.1s ease, background 0.2s, box-shadow 0.2s;
}
.btn-primary:hover,
.save-btn:hover {
    background: var(--orange-hover);
    box-shadow: var(--shadow-button-strong);
}
.btn-primary:active,
.save-btn:active { transform: scale(0.98); }
.btn-primary:disabled,
.save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Inline save button (next to input) */
.save-btn {
    border-radius: 12px;
    font-size: 15px;
    padding: 0 22px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* CTA pill (large primary, used in onboarding / hero spots) */
.btn-cta {
    background: var(--orange);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    padding: 16px 44px;
    border-radius: var(--radius-pill);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-button-strong);
    transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}
.btn-cta:hover {
    background: var(--orange-hover);
    box-shadow: 0 12px 28px rgba(255, 122, 0, 0.36);
}
.btn-cta:active { transform: scale(0.97); }

/* Secondary text link */
.btn-text {
    background: none;
    border: none;
    color: var(--muted-soft);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    font-family: inherit;
    transition: color 0.2s;
}
.btn-text:hover { color: var(--text); }

/* Danger button (sign out, destructive actions) */
.danger-btn {
    width: 100%;
    border: 2px solid var(--danger);
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--danger);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 22px;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s, color 0.2s;
}
.danger-btn:hover { background: var(--danger); color: #fff; }
.danger-btn:active { transform: scale(0.98); }

/* =========================================================================
   Pills (pronoun selectors, filter chips, etc.)
   ========================================================================= */
.pill-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.pill {
    flex: 1 1 0;
    min-width: 0;
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.6);
    color: #333;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.1s, box-shadow 0.2s;
    white-space: nowrap;
}
.pill:hover { background: rgba(255, 255, 255, 0.85); }
.pill:active { transform: scale(0.97); }
.pill.active {
    background: var(--orange);
    color: #fff;
    border-color: var(--orange);
    box-shadow: 0 6px 14px rgba(255, 122, 0, 0.22);
}
.pill:disabled { opacity: 0.6; cursor: not-allowed; }

/* =========================================================================
   Save status (auto-save feedback)
   ========================================================================= */
.save-status {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: var(--success);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    min-height: 18px;
}
.save-status.visible { opacity: 1; }
.save-status.error { color: var(--danger); }

/* =========================================================================
   Avatar (circular preview, used in account / onboarding)
   ========================================================================= */
.avatar-row {
    display: flex;
    align-items: center;
    gap: 18px;
}
.avatar-preview {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--white-soft-2);
    border: 2px solid rgba(255, 255, 255, 0.6);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.avatar-preview svg {
    width: 60%;
    height: 60%;
    opacity: 0.55;
}
.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 520px) {
    .page { padding-left: 20px; padding-right: 20px; }
    .animus-nav { padding-left: 20px; padding-right: 20px; }
    .card,
    .section { padding: 20px; }
}

/* =========================================================================
   Page transition: cross-page dissolve via overlay mask (NOT body opacity).

   Why this shape (three failed attempts before this one — read the why):

   1. **First try (children-level `body > * { animation: forwards }`)**
      forwards-locked opacity:1 on every direct body child. Broke any page
      that wanted scroll-reveal on direct body sections (family-about repro).

   2. **Second try (body-level `body { animation: forwards }`)** fixed the
      lock but made the top nav fade in with content — testers rejected it
      on both owner and family side ("nav should never flicker").

   3. **This shape (cream-colored mask via `::before`)** keeps the dissolve
      effect without animating body or its children: a fixed-position layer
      the same color as the page background covers everything underneath,
      fades from opacity 1 → 0 on load, and reverse-fades 0 → 1 when
      `.page-leaving` is set. Nav and menu chrome live above the mask via
      a higher z-index, so they're visible from frame 0 and never animate.
      Body and all descendants keep their natural opacity / animation /
      transition behavior — no forwards-lock, no `.reveal` regression.

   Mask z-index = 150. Anything that should stay visible during the fade
   must sit above 150 (.animus-nav is bumped to 200 in menu.js to match
   the existing standalone nav patterns on owner-onboarding / family-*).

   Fade-IN is pure CSS so it works on EVERY owner page regardless of
   whether menu.js is loaded (e.g. owner-onboarding doesn't load menu.js).
   Fade-OUT requires JS to add `.page-leaving`; pages without menu.js
   hard-cut on navigation — acceptable graceful degradation.
   ========================================================================= */
body.owner::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 150;
    pointer-events: none;
    animation: owner-mask-fade-out 220ms ease-out forwards;
}
@keyframes owner-mask-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
body.owner.page-leaving::before {
    animation: none;
    opacity: 1;
    transition: opacity 180ms ease-in;
}

/* =========================================================================
   Reduced motion: 整个主人端兜底。把 keyframes 折叠成单次瞬时执行，
   transition 缩到不可感知，scroll-behavior 退回 auto。功能保持，运动消除。
   prefers-reduced-motion 也直接关掉 page transition，instant cut。
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    body.owner::before,
    body.owner.page-leaving::before {
        opacity: 0 !important;
        transition: none !important;
        animation: none !important;
    }
}
