/* Global Styles — legacy layer of the Contee Océan charte.
   Historical variable names kept (the layer is shrinking toward the
   tailwind tokens in style/tailwind.css); VALUES are the Océan palette.
   Both surfaces are documented in docs/brand/color-palette.md. */
:root {
    --primary-color: #245b78;   /* Océan */
    --primary-light: #347aa5;   /* Ocean Accent */
    --text-color: #243039;      /* Ocean Ink */
    --text-light: #66747d;      /* Ocean Muted */
    --bg-color: #f7f9fa;        /* Ocean Background */
    --bg-section: #eff4f7;      /* Ocean Panel */
    --white: #ffffff;           /* text/borders ON colored surfaces — stays light in dark mode */
    --surface: #ffffff;         /* Surface — cards, header, panels (darkens in dark mode) */
    --accent-color: #347aa5;    /* Ocean Accent */
    --line-color: #dce5ea;      /* Ocean Line */
    --terracotta: #c9785b;      /* Contee signature — punctuation only */

    /* Ocean-tinted elevation (charte §5.3) */
    --shadow-soft: 0 8px 24px rgb(36 91 120 / 6.5%);
    --shadow-panel: 0 16px 42px rgb(36 91 120 / 8.5%);

    /* ONE serif family site-wide (founder revision 2026-09-08, after
       live review: the serif/sans mix read as two products — the brand
       serif applies everywhere, converging with the template's choice).
       Option A system stack, zero webfont (check-no-webfonts gate);
       weights stay one notch down (system serifs run heavier than
       Cormorant). Deliberate exception: the scan panels keep their mono
       (the charte's technical face — placeholders read as tokens). */
    --font-heading: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
    --font-body: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", "URW Palladio L", P052, Georgia, serif;

    color-scheme: light;
}

/* Dark palette (charte §2.5) — same WCAG-computed values as the tailwind
   .dark block (see backlog/2026-08-29-dark-mode-theme-toggle.md for the
   ratio table). --white deliberately NOT overridden: it carries the
   text-on-colored-surface role and stays light. */
.dark {
    --primary-color: #5d93b0;
    --primary-light: #74a9c6;
    --text-color: #e7ecef;
    --text-light: #9ca9b3;
    --bg-color: #101820;
    --bg-section: #1f2b36;
    --surface: #18222c;
    --accent-color: #74a9c6;
    --line-color: #2e3b47;
    --terracotta: #cd8d74;
    --shadow-soft: 0 4px 14px rgb(0 0 0 / 40%);
    --shadow-panel: 0 8px 22px rgb(0 0 0 / 50%);

    color-scheme: dark;
}

/* The warm day (Contee charter § 2.6) — the same values as the tailwind
   .warm block: warm neutrals, Ocean accents. */
.warm {
    --text-color: #33261f;
    --text-light: #76605a;
    --bg-color: #faede6;
    --bg-section: #f3e2d8;
    --surface: #fff8f4;
    --line-color: #e6d0c4;

    color-scheme: light;
}

/* The language picker: the flag, then the name (Contee charter § 7.1). */
.language-choice {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
}

/* Surfaces whose light-mode value is not variable-driven: the Ocean footer
   becomes a panel anchor. (The template's gallery pages and their rules left
   on 2026-09-26: the surrounding pages live in style/site.css.) */
.dark footer {
    background-color: var(--bg-section);
    border-top: 1px solid var(--line-color);
}

body {
    font-family: var(--font-body);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
}

/* Form controls do NOT inherit font-family by default (and Tailwind's
   preflight is deliberately not imported) — without this, inputs render
   in the UA font and textareas in monospace. */
input,
textarea,
select,
button {
    font-family: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    margin-bottom: 0.5em;
    font-weight: 600;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 150ms var(--ease-s);
}

/* Focus always visible (charte §10) — Ocean Accent ring for the legacy
   surfaces; rust-ui components carry their own --ring-based focus. */
:focus-visible {
    outline: 3px solid rgb(52 122 165 / 45%);
    outline-offset: 2px;
}

/* Motion explains state, it does not decorate (charte §9) — and steps
   aside entirely when the user asks. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background-color: var(--surface);
    border-bottom: 1px solid var(--line-color);
    box-shadow: 0 2px 8px rgb(36 91 120 / 5%);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.logo-mark {
    height: 2rem;
    width: auto;
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

nav a {
    font-weight: 500;
    color: var(--primary-color);
}

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

/* Account menu (authenticated UX). BOTH variants are always rendered; the
 * shell sets html.authed / html.anon (see html_shell) and CSS reveals one — no
 * client-side principal, so no SSR/hydration mismatch. Default (class absent or
 * anon) shows the anon variant (Log in). */
.nav-auth {
    font-weight: 500;
    color: var(--primary-color);
}
.nav-auth:hover {
    color: var(--primary-light);
}
.nav-account {
    align-items: center;
}
.nav-account-anon {
    display: flex;
}
.nav-account-authed {
    display: none;
}
html.authed .nav-account-anon,
html.sign-in-off .nav-account-anon {
    display: none;
}
html.authed .nav-account-authed {
    display: flex;
}

/* The authenticated chip: a monogram avatar + the display name. Reuses the
 * nav-dropdown trigger/menu machinery (:focus-within, no JS). */
.account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--surface);
    font-size: 0.8rem;
    font-weight: 600;
}
.account-name {
    font-weight: 500;
}
.account-menu {
    min-width: 200px;
}
/* Identity header inside the menu: the email, set off from the actions. */
.account-identity {
    padding: 0.4rem 1rem 0.5rem;
    border-bottom: 1px solid var(--line-color);
}
.account-email {
    font-size: 0.8rem;
    color: var(--primary-light);
    word-break: break-all;
}
/* Logout is state-changing → a POST <form> (never a GET reachable by
 * prefetch/<img>). Its two scope buttons read as full-width menu rows. */
.account-logout-form {
    display: flex;
    flex-direction: column;
}
.account-menu-item {
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--primary-color);
    white-space: nowrap;
}
.account-menu-item:hover {
    background: var(--bg-color);
    color: var(--primary-light);
}

/* /account — the gated authenticated page (Part 2). Server-rendered from the
   Principal; reached via a rel="external" full load (see auth::page_gate). */
.account-page {
    max-width: 640px;
    margin: 0 auto;
}
.account-lead {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}
.account-details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    margin-top: 1.5rem;
}
.account-details dt {
    font-weight: 600;
    color: var(--primary-light);
}
.account-details dd {
    margin: 0;
    word-break: break-all;
}

/* Navigation Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    font-weight: 500;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-dropdown-trigger::after {
    content: '▾';
    font-size: 0.75rem;
}

.nav-dropdown-trigger:hover {
    color: var(--primary-light);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--line-color);
    box-shadow: var(--shadow-soft);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms var(--ease-s), visibility 200ms;
    flex-direction: column;
    gap: 0;
    z-index: 1001;
}

/* :focus-within complements :hover so the menu also opens via keyboard (Tab
   onto the tabindex'd trigger) and touch (tap focuses it) — hover-only menus
   are unusable on touch devices. Pure CSS: works pre-hydration and no-JS. */
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.nav-dropdown-menu li {
    padding: 0;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    color: var(--primary-color);
}

.nav-dropdown-menu a:hover {
    background: var(--bg-color);
    color: var(--primary-light);
}

/* Sections */
section {
    padding: 4rem 5%;
}

/* Footer — Ocean anchor surface */
footer {
    text-align: center;
    padding: 3rem 5%;
    background-color: var(--primary-color);
    color: var(--white);
    margin-top: 2rem;
}

.footer-logo {
    height: 2.5rem;
    width: auto;
    margin-bottom: 1.25rem;
}

footer p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.footer-legal {
    margin-bottom: 1rem;
}

.footer-legal a {
    color: var(--white);
    opacity: 0.7;
    font-size: 0.85rem;
}

.footer-legal a:hover {
    opacity: 1;
}

/* Legal Page */
.legal-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 5%;
}

.legal-page h1 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.legal-page h2 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.legal-page p {
    margin-bottom: 1rem;
}

.legal-page a {
    color: var(--primary-light);
    text-decoration: underline;
}

.legal-page ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.legal-page li {
    margin-bottom: 0.5rem;
}

/* Language picker (i18n, ADR-0020) */
.lang-trigger {
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.lang-menu {
    min-width: 140px;
    max-height: 60vh;
    overflow-y: auto;
}

.lang-menu a[aria-current="true"] {
    font-weight: 600;
    color: var(--accent-color);
}
