/* ───────────────────────────────────────────────────────
   VetOS Portal — app shell (header / nav / main / footer).
   Component classes live in nimbus.css; tokens are defined
   there (:root) and consumed here.
─────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    color: var(--color-ink);
    background: var(--color-canvas-parchment);
}

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

.portal-root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Suppress the default focus ring on programmatically-focused page headings.
   Blazor's <FocusOnNavigate Selector="h1" /> sets focus on every navigation;
   keyboard users still get :focus-visible for genuine tab-focus.            */
h1:focus {
    outline: none;
}

.portal-header {
    background: rgba(245, 245, 247, 0.96);
    backdrop-filter: var(--blur-frost);
    -webkit-backdrop-filter: var(--blur-frost);
    border-bottom: 1px solid var(--color-hairline);
    /* No shadow — Nimbus header treatment is parchment frosted, hairline bottom. */
    position: sticky;
    top: 0;
    z-index: 10;
}

.portal-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 1.5rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Brand lockup — mirrors the clinical app: a dark rounded "V." square, the
   "VetOS." wordmark with an Action-Blue dot, and a muted "Portal" subtitle. */
.portal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.portal-brand-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-ink);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.05em;
    border-radius: var(--radius-sm);
}
.portal-brand-lockup {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.portal-brand-text {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--color-ink);
    letter-spacing: -0.02em;
}
.portal-brand-dot { color: var(--color-primary); }
.portal-brand-sub {
    font-size: 11px;
    font-weight: 400;
    color: var(--color-ink-muted-56);
    letter-spacing: 0.01em;
}

.portal-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;   /* float the nav + account cluster to the right of the brand */
}

.portal-nav a {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-ink);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.portal-nav a:hover {
    background: var(--color-divider-soft);
    color: var(--color-ink);
}

/* Active route — a soft Action-Blue pill (the same info-tint the app uses on
   chips and the info alert), NOT a lone bottom border that reads as a stray
   edge around the selected item. */
.portal-nav a.active {
    background: var(--color-info-tint);
    color: var(--color-primary);
}

/* A mouse click must never leave the browser's default focus outline box around
   the clicked item; keyboard users still get a clear focus ring. */
.portal-nav a:focus,
.portal-account > summary:focus,
.portal-menu > summary:focus,
.portal-menu-item:focus { outline: none; }
.portal-nav a:focus-visible,
.portal-account > summary:focus-visible,
.portal-menu > summary:focus-visible,
.portal-menu-item:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ── Account control (authenticated) — native <details> dropdown ──────────── */
.portal-account { position: relative; }
.portal-account > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.6rem 0.25rem 0.3rem;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    cursor: pointer;
    list-style: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.portal-account > summary::-webkit-details-marker { display: none; }
.portal-account > summary::marker { content: ""; }
.portal-account > summary:hover { background: var(--color-divider-soft); }
.portal-account[open] > summary {
    background: var(--color-divider-soft);
    border-color: var(--color-hairline);
}
.portal-avatar { width: 30px; height: 30px; font-size: 0.75rem; }
.portal-account-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-ink);
    max-width: 14ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.portal-caret {
    width: 14px;
    height: 14px;
    color: var(--color-ink-muted-56);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}
.portal-account[open] .portal-caret { transform: rotate(180deg); }

/* Shared dropdown surface — account menu and mobile menu. */
.portal-account-menu,
.portal-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 224px;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem;
    background: var(--color-canvas);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-product);
    z-index: 60;
}
.portal-account-menu form,
.portal-menu-panel form { margin: 0; }

.portal-account-head {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.65rem 0.6rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--color-divider-soft);
}
.portal-account-head-name { font-size: 0.875rem; font-weight: 700; color: var(--color-ink); }
.portal-account-head-email {
    font-size: 0.78rem;
    color: var(--color-ink-muted-56);
    overflow-wrap: anywhere;
}

.portal-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-ink);
    text-align: left;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
}
.portal-menu-item:hover { background: var(--color-divider-soft); color: var(--color-ink); }
.portal-menu-item.active { background: var(--color-info-tint); color: var(--color-primary); }
.portal-menu-item-primary { color: var(--color-primary); }
.portal-menu-signout { color: var(--color-danger); }
.portal-menu-signout:hover { background: var(--color-danger-tint); color: var(--color-danger); }

/* ── Anonymous CTA cluster ────────────────────────────────────────────────── */
.portal-auth-cta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Mobile hamburger (native <details>) ──────────────────────────────────── */
.portal-menu { position: relative; }
.portal-menu > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    color: var(--color-ink);
    cursor: pointer;
    list-style: none;
}
.portal-menu > summary::-webkit-details-marker { display: none; }
.portal-menu > summary::marker { content: ""; }
.portal-menu > summary:hover { background: var(--color-divider-soft); }
.portal-menu[open] > summary {
    background: var(--color-divider-soft);
    border-color: var(--color-hairline);
}
.portal-menu-icon { display: inline-flex; }
.portal-menu-icon svg { width: 22px; height: 22px; }

/* Accessibility: hide content visually but keep it in the a11y tree. Used
   to attach `<label>` to fields where a visible label would clutter the UI
   (search inputs with explicit placeholders, etc.). */
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Portal footer — small, muted, never competes with body content. */
.portal-footer {
    margin-top: 3rem;
    border-top: 1px solid var(--color-hairline);
    background: var(--color-canvas-parchment);
}
.portal-footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.825rem;
    color: var(--color-ink-muted-56);
}
.portal-footer-nav {
    display: flex;
    gap: 0.25rem;
}
.portal-footer-nav a {
    color: var(--color-ink);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-xs);
    font-weight: 600;
    transition: color 0.15s;
}
.portal-footer-nav a:hover,
.portal-footer-nav a:focus-visible {
    color: var(--color-primary);
}
.portal-footer-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--color-ink-muted-56);
}

.portal-main {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* Hamburger is desktop-hidden; the inline nav + account/CTA cluster carry the
   bar on wide screens. */
.portal-menu { display: none; }

/* Tablet — keep the full bar but drop the account name text to save room. */
@media (max-width: 900px) {
    .portal-account-name { display: none; }
}

/* ── Mobile (<= 720px) — collapse the nav + account into the hamburger ────── */
@media (max-width: 720px) {
    .portal-header-inner {
        padding: 0 0.9rem;
        min-height: 56px;
    }
    .portal-nav,
    .portal-account,
    .portal-auth-cta { display: none; }
    .portal-menu {
        display: inline-flex;
        margin-left: auto;
    }
    .portal-main { padding: 1.25rem 0.9rem 2.5rem; }
}
