/* ==========================================================
   Andy Command — hub stylesheet

   Accessibility is the first constraint here, not a later
   polish (§48). That drives:
     - a 17px base and everything sized in rem, so browser
       zoom and OS text scaling both work properly
     - text contrast at or above WCAG AA on every colour pair
     - focus outlines that are impossible to miss
     - 44px minimum on anything clickable
     - status shown as WORDS as well as colour, never colour
       alone
     - High Visibility Mode: bigger, plainer, less on screen
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@500;600&display=swap');

:root {
    --bg:        #05080d;
    --panel:     #0a141d;
    --panel-2:   #0e1a25;
    --line:      rgba(215, 164, 63, .28);
    --line-soft: rgba(255, 255, 255, .12);

    --text:      #f6f5f0;
    --muted:     #b9c1c9;   /* 7.2:1 on --panel */
    --gold:      #d7a43f;
    --gold-2:    #f0c66f;

    --red:       #ff8a80;
    --orange:    #ffb26b;
    --amber:     #ffd97d;
    --green:     #86e0a8;

    --radius:    10px;
    --base-size: 17px;
    --shell:     min(1280px, calc(100% - 48px));
}

* { box-sizing: border-box; }

html {
    font-size: var(--base-size);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', system-ui, -apple-system, Arial, sans-serif;
    line-height: 1.6;
}

/* ---------- Focus: loud on purpose ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--gold-2);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: -9999px;
}
.skip-link:focus {
    left: 12px;
    top: 12px;
    z-index: 999;
    background: var(--gold-2);
    color: #05080d;
    padding: 14px 20px;
    font-weight: 700;
    border-radius: 6px;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Layout ---------- */
.shell { width: var(--shell); margin-inline: auto; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(4, 8, 13, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    min-height: 68px;
    padding-block: .5rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: inherit;
}
.brand-mark {
    font: 600 2rem/1 'Playfair Display', serif;
    color: var(--gold-2);
    letter-spacing: -2px;
}
.brand-copy strong {
    display: block;
    font-family: 'Playfair Display', serif;
    font-weight: 500;
    font-size: 1.15rem;
}
.brand-copy small {
    display: block;
    color: var(--gold);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.topbar-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.topbar-user { color: var(--muted); font-size: .9rem; }

nav.mainnav {
    border-bottom: 1px solid var(--line-soft);
    background: var(--panel);
}
nav.mainnav ul {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
nav.mainnav a {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 0 1.15rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: .95rem;
    border-bottom: 3px solid transparent;
}
nav.mainnav a:hover { background: var(--panel-2); color: var(--gold-2); }
nav.mainnav a[aria-current="page"] {
    color: var(--gold-2);
    border-bottom-color: var(--gold);
    background: var(--panel-2);
}

main { padding: 2rem 0 5rem; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}
.page-head h1 {
    font: 500 clamp(1.9rem, 3.4vw, 2.6rem)/1.15 'Playfair Display', serif;
    margin: 0;
}
.page-head p { margin: .4rem 0 0; color: var(--muted); }

h2 { font: 500 1.5rem/1.25 'Playfair Display', serif; margin: 0 0 .85rem; }
h3 { font-size: 1.1rem; margin: 0 0 .5rem; }

/* ---------- Panels ---------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.panel > h2 { border-bottom: 1px solid var(--line-soft); padding-bottom: .65rem; }

.grid { display: grid; gap: 1.25rem; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.four  { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- Stat tiles ---------- */
.stat {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    display: block;
}
a.stat:hover { border-color: var(--gold); background: #12202c; }
.stat strong {
    display: block;
    font: 600 2.1rem/1 'Playfair Display', serif;
    color: var(--gold-2);
}
.stat span { display: block; margin-top: .4rem; font-size: .9rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 46px;
    padding: .6rem 1.25rem;
    border: 1px solid var(--gold);
    border-radius: 6px;
    background: transparent;
    color: var(--gold-2);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: rgba(215, 164, 63, .14); }
.button-primary {
    background: linear-gradient(135deg, #f1ca72, #c68a25);
    border-color: transparent;
    color: #07090c;
}
.button-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #f1ca72, #c68a25); }
.button-quiet { border-color: var(--line-soft); color: var(--text); }
.button-danger { border-color: #b85e5e; color: var(--red); }
.button-small { min-height: 38px; padding: .35rem .8rem; font-size: .85rem; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 1.15rem; }
form label, .field > span.label {
    display: block;
    font-weight: 600;
    margin-bottom: .4rem;
    font-size: .95rem;
}
.field .hint {
    display: block;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 400;
    margin-bottom: .4rem;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], input[type="url"], input[type="search"],
select, textarea {
    width: 100%;
    min-height: 46px;
    padding: .65rem .8rem;
    background: #050a10;
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
select { min-height: 46px; }
input::placeholder, textarea::placeholder { color: #7d868f; }

fieldset {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 0 0 1.5rem;
}
legend { padding: 0 .5rem; font-weight: 700; color: var(--gold-2); }

.form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    padding-top: .5rem;
    border-top: 1px solid var(--line-soft);
    margin-top: 1.25rem;
}

/* ---------- Messages ---------- */
.alert {
    padding: 1rem 1.15rem;
    border: 1px solid;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-weight: 500;
}
.alert.success { border-color: #4f9a72; background: #0c2418; color: #cdf3dd; }
.alert.error   { border-color: #b85e5e; background: #2a1010; color: #ffd9d5; }
.alert.info    { border-color: var(--gold); background: #1d1708; color: #f4e3bf; }
.alert strong { display: block; margin-bottom: .25rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
caption { text-align: left; color: var(--muted); padding-bottom: .6rem; font-size: .9rem; }
th, td {
    text-align: left;
    padding: .85rem .75rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}
th { color: var(--gold-2); font-size: .82rem; text-transform: uppercase; letter-spacing: 1px; }
tbody tr:hover { background: var(--panel-2); }
td a { color: var(--gold-2); font-weight: 600; }

/* ---------- Status pills ----------
   The word carries the meaning. The colour only reinforces it,
   which is what §48 requires. */
.pill {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 999px;
    border: 1px solid currentColor;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.pill-red    { color: var(--red); }
.pill-orange { color: var(--orange); }
.pill-amber  { color: var(--amber); }
.pill-green  { color: var(--green); }
.pill-grey   { color: var(--muted); }

.verify-ai   { color: var(--orange); font-weight: 700; }
.verify-unverified { color: var(--muted); }
.verify-verified   { color: var(--green); }

/* ---------- Progress ---------- */
.progress {
    display: block;
    height: 12px;
    background: #0a1219;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    overflow: hidden;
    margin: .5rem 0;
}
.progress i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #c68a25, #f1ca72);
}

/* ---------- Relationship list ---------- */
.rel-list { list-style: none; margin: 0; padding: 0; }
.rel-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .85rem 0;
    border-bottom: 1px solid var(--line-soft);
}
.rel-list .rel-label { color: var(--muted); }
.rel-list .rel-target { font-weight: 700; color: var(--gold-2); }
.rel-list .historical { opacity: .65; }

.empty {
    padding: 2rem;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--line-soft);
    border-radius: var(--radius);
}

.muted { color: var(--muted); }
.dl-plain { margin: 0; }
.dl-plain dt { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; margin-top: 1rem; }
.dl-plain dd { margin: .25rem 0 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.login-card {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 2.25rem;
}
.login-card h1 { font: 500 2rem/1.1 'Playfair Display', serif; margin: 0 0 .35rem; }
.login-card .button { width: 100%; }

/* ---------- Footer ---------- */
.hub-footer {
    border-top: 1px solid var(--line-soft);
    padding: 1.5rem 0;
    color: var(--muted);
    font-size: .85rem;
}

/* ==========================================================
   HIGH VISIBILITY MODE (§48)
   Bigger type, plainer surfaces, fewer competing edges.
   ========================================================== */
body.high-vis {
    --base-size: 22px;
    --muted: #dfe4e9;
    --panel: #0d1720;
    --panel-2: #12202c;
    --line-soft: rgba(255, 255, 255, .3);
}
body.high-vis html, body.high-vis { font-size: 22px; }
body.high-vis { line-height: 1.75; }
body.high-vis .stat strong { font-size: 2.6rem; }
body.high-vis nav.mainnav a { min-height: 62px; font-size: 1.05rem; }
body.high-vis .button { min-height: 56px; font-size: 1rem; }
body.high-vis input, body.high-vis select, body.high-vis textarea { min-height: 56px; font-size: 1rem; }
body.high-vis th { font-size: .95rem; }
body.high-vis .pill { font-size: .95rem; padding: .3rem .8rem; }
/* Reduce visual noise: drop decorative gradients. */
body.high-vis .button-primary { background: #f1ca72; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    html { scroll-behavior: auto; }
}

@media (max-width: 760px) {
    :root { --shell: min(100% - 24px, 700px); }
    .topbar-inner { flex-wrap: wrap; }
    nav.mainnav a { padding: 0 .85rem; font-size: .9rem; }
    .page-head { flex-direction: column; align-items: flex-start; }
    th, td { padding: .7rem .5rem; }
}

@media print {
    body { background: #fff; color: #000; }
    .topbar, nav.mainnav, .hub-footer, .no-print { display: none !important; }
    .panel { border: 1px solid #999; break-inside: avoid; }
    a { color: #000; text-decoration: underline; }
}
