/*
 * SafeShare, aligned with the NoA Ignite brand (tokens taken from noaignite.com).
 *
 * Typefaces: noaGrotesk (UI, labels, buttons) and noaSerif (headings) are NoA Ignite's licensed brand fonts
 * and are NOT included in this repository. Put the licensed .woff2 files in wwwroot/fonts/ with the names
 * below and they are picked up automatically. Until then, the metric-matched Arial fallbacks (the same ones
 * noaignite.com uses) keep the layout identical. Inter (body text) is bundled under the SIL OFL.
 */

/* ---------- fonts ---------- */

@font-face { font-family: "noaGrotesk"; src: url(../fonts/noaGrotesk-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "noaGrotesk"; src: url(../fonts/noaGrotesk-Medium.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "noaGrotesk"; src: url(../fonts/noaGrotesk-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "noaSerif"; src: url(../fonts/noaSerif-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "noaSerif"; src: url(../fonts/noaSerif-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "noaGrotesk Fallback"; src: local("Arial"); ascent-override: 80.43%; descent-override: 23.87%; line-gap-override: 0%; size-adjust: 122.34%; }

@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-700.woff2) format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-ext-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-ext-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; src: url(../fonts/inter-latin-ext-700.woff2) format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- brand tokens (noaignite.com) ---------- */

:root {
    --noa-black: #000000;
    --noa-dark: #151d1f;          /* --color-dark */
    --noa-dark-mid: #313b3b;      /* --color-dark-mid */
    --noa-mid: #547178;           /* --color-mid */
    --noa-mid-light: #c2e0e7;     /* --color-mid-light */
    --noa-light: #e0f5f6;         /* --color-light */
    --noa-white: #ffffff;
    --noa-white-off: #ebeaea;     /* --color-white-off / background-secondary */
    --noa-sand: #e7ded1;          /* --color-background-tertiary */
    --noa-grey: #d8d5d5;          /* --color-grey-light */
    --noa-pink: #ff46cd;          /* --color-pink (brand spot, logo square, hover) */
    --noa-yellow: #e4fb00;        /* --color-yellow / brand3 (highlight) */
    --noa-purple: #a681f7;        /* brand4 */
    --noa-error: #e30002;
    --noa-success: #4caf50;
    --noa-disabled: #828282;

    --font-sans: "noaGrotesk", "noaGrotesk Fallback", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    /* Georgia rather than the metric-matched Arial: until noaSerif is installed, a serif keeps headings on-brand. */
    --font-serif: "noaSerif", Georgia, Cambria, "Times New Roman", serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, "Liberation Mono", monospace;

    --radius: 0.25rem;            /* --border-radius-base */
    --radius-input: 0.188rem;     /* --border-radius-input */
    --radius-card: 0.313rem;      /* --border-radius-image */

    /* semantic (light theme) */
    --bg: var(--noa-white);
    --surface: var(--noa-white-off);
    --surface-alt: var(--noa-sand);
    --field: var(--noa-white);
    --text: var(--noa-dark);
    --text-muted: #4f4f4f;        /* --color-text-secondary */
    --divider: #c2c2c2;           /* --color-divider-primary */
    --strong-border: var(--noa-dark);
    --btn-bg: var(--noa-dark);
    --btn-text: var(--noa-white);
    --btn-hover-bg: var(--noa-pink);
    --btn-hover-text: var(--noa-dark);
    --outline-hover-bg: var(--noa-dark-mid);
    --outline-hover-text: var(--noa-light);
    --highlight: var(--noa-yellow);
    --highlight-text: var(--noa-black);
    --link: var(--noa-dark);
    --link-hover: var(--noa-mid);
    --footer-bg: var(--noa-dark);
    --check-accent: var(--noa-dark);
    --error-text: var(--noa-error);
    color-scheme: light;
}

/* Dark theme. The header switch sets data-theme on <html>: "light" (the default, rendered by the server) and
   "dark" always win; no attribute ("auto") follows the operating system. Keep the two token blocks identical. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: var(--noa-dark);
        --surface: var(--noa-dark-mid);
        --surface-alt: #263030;
        --field: var(--noa-dark);
        --text: var(--noa-white);
        --text-muted: #afadac;    /* --color-brand2-quaternary */
        --divider: var(--noa-mid);
        --strong-border: var(--noa-white);
        --btn-bg: var(--noa-white);
        --btn-text: var(--noa-dark);
        --outline-hover-bg: var(--noa-light);
        --outline-hover-text: var(--noa-dark);
        --link: var(--noa-white);
        --link-hover: var(--noa-mid-light);
        --footer-bg: var(--noa-black);
        --check-accent: var(--noa-white);
        --error-text: #ff6b6d;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: var(--noa-dark);
    --surface: var(--noa-dark-mid);
    --surface-alt: #263030;
    --field: var(--noa-dark);
    --text: var(--noa-white);
    --text-muted: #afadac;    /* --color-brand2-quaternary */
    --divider: var(--noa-mid);
    --strong-border: var(--noa-white);
    --btn-bg: var(--noa-white);
    --btn-text: var(--noa-dark);
    --outline-hover-bg: var(--noa-light);
    --outline-hover-text: var(--noa-dark);
    --link: var(--noa-white);
    --link-hover: var(--noa-mid-light);
    --footer-bg: var(--noa-black);
    --check-accent: var(--noa-white);
    --error-text: #ff6b6d;
    color-scheme: dark;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute must win over component display rules (e.g. .field { display: flex }),
   otherwise elements the scripts hide, such as the key field on a link that already has the key, stay visible. */
[hidden] { display: none !important; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 400 1rem/1.35 var(--font-body);
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 400; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 2.75rem); line-height: 1.1; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.2; margin-top: 1.6em; }
h3 { font-size: 1.25rem; line-height: 1.3; }

p { margin: 0 0 1em; }

a { color: var(--link); text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }

code { font-family: var(--font-mono); font-size: .9em; background: var(--surface); padding: .1em .35em; border-radius: var(--radius-input); }

:focus-visible { outline: 2px solid var(--strong-border); outline-offset: 2px; }

.skip-link { position: absolute; left: -9999px; top: 0; z-index: 30; background: var(--highlight); color: var(--highlight-text); padding: .5rem 1rem; }
.skip-link:focus { left: 1rem; top: 1rem; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding-inline: 1.5rem; }
@media (min-width: 1024px) { .wrap { padding-inline: 3rem; } }

.muted { color: var(--text-muted); }
.small { font-size: .875rem; }

/* ---------- header / footer ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--divider);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 4.5rem; flex-wrap: wrap; padding-block: .75rem; }

.brand { display: inline-flex; align-items: center; gap: .9rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand:active { opacity: .7; }
.logo { display: block; width: auto; height: 1.75rem; }
.brand-name {
    font: 400 .875rem/1.3 var(--font-sans);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-left: .9rem;
    border-left: 1px solid var(--divider);
}

.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1.75rem; }
.topbar nav a {
    font: 400 .875rem/1.3 var(--font-sans);
    text-transform: uppercase;
    color: var(--text);
    text-decoration: none;
    padding-block: .35rem;
    border-bottom: 2px solid transparent;
}
.topbar nav a:hover { border-bottom-color: var(--noa-pink); color: var(--text); }
.topbar nav a[aria-current="page"] { border-bottom-color: var(--strong-border); }

.header-end { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem 2rem; }

/* Light / Dark / Auto switch: a segmented control in the brand's outlined-button style. */
.theme-switch { display: inline-flex; border: 1px solid var(--strong-border); border-radius: var(--radius); overflow: hidden; }
.theme-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: transparent;
    border: 0;
    padding: .45rem .55rem;
    cursor: pointer;
}
.theme-switch button + button { border-left: 1px solid var(--strong-border); }
.theme-switch button:hover { background: var(--surface); }
.theme-switch button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-text); }
.theme-switch svg { width: .95rem; height: .95rem; flex-shrink: 0; }

.main { flex: 1; padding-block: 3rem 4rem; }

.footer { background: var(--footer-bg); color: var(--noa-white); margin-top: auto; }
.footer-inner { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; padding-block: 2rem; font: 400 .875rem/1.3 var(--font-sans); text-transform: uppercase; }
.footer .logo { height: 1.4rem; }

/* ---------- panels ---------- */

.panel { background: var(--bg); }
.panel.narrow { max-width: 760px; margin: 0 auto; }
.panel.center { text-align: center; max-width: 640px; margin: 2rem auto; }
.panel.center .btn { margin-inline: auto; }

/* Lead paragraph under a page title. */
.panel h1 + p, .panel h1 + .muted { font-size: 1.125rem; }

/* Grouped boxes use the brand's light grey surface, flat with a small radius. */
.share-option, .timer {
    background: var(--surface);
    border-radius: var(--radius-card);
}

.prose li { margin-bottom: .4rem; }
.prose ol, .prose ul { padding-left: 1.25rem; }

/* ---------- two-column pages: action on the left, explanation on the right ---------- */

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(17rem, 23rem);
    gap: 2.5rem 4rem;
    align-items: start;
}
.split-main .panel.narrow { max-width: none; margin: 0; }

.explain {
    position: sticky;
    top: 6.5rem;                               /* below the sticky header */
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    background: var(--surface-alt);
    border-radius: var(--radius-card);
    padding: 1.5rem 1.6rem;
    font-size: .9375rem;
    line-height: 1.45;
}
.explain .eyebrow { font: 400 .75rem/1.3 var(--font-sans); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: .6rem; }
.explain h2 { font-size: 1.6rem; margin: 0 0 .75rem; }
.explain h3 { font-size: 1.1rem; margin: 1.4rem 0 .4rem; }
.explain ol, .explain ul { padding-left: 1.15rem; margin: 0 0 .9rem; }
.explain li { margin-bottom: .45rem; }
.explain p:last-child, .explain ul:last-child { margin-bottom: 0; }
.explain code { background: var(--bg); }

@media (max-width: 960px) {
    .split { grid-template-columns: minmax(0, 1fr); }
    .explain { position: static; max-height: none; }
}

/* Short must-know notes that stay next to the form. */
.note { font-size: .9rem; border-left: 3px solid var(--highlight); padding: .15rem 0 .15rem .75rem; margin: 1rem 0 1.25rem; }
.facts { list-style: none; padding: 0; margin: 1.25rem 0; font-size: .9375rem; }
.facts li { padding: .4rem 0; border-top: 1px solid var(--divider); }
.facts li:last-child { border-bottom: 1px solid var(--divider); }
.field-like { font: 400 .875rem/1.3 var(--font-sans); text-transform: uppercase; margin: 0 0 .6rem; }

/* ---------- forms ---------- */

.input, .editor {
    font: inherit;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--divider);
    border-radius: var(--radius-input);
    padding: .7rem .85rem;
    width: 100%;
    transition: border-color .15s;
}
.input:hover, .editor:hover { border-color: var(--text-muted); }
.input:focus, .editor:focus { outline: none; border-color: var(--strong-border); box-shadow: 0 0 0 1px var(--strong-border); }
.input:disabled { opacity: .55; }
.input.mono, .copy-row .input { font-family: var(--font-mono); font-size: .9rem; }

.editor {
    display: block;
    min-height: 15rem;
    resize: vertical;
    font: .9rem/1.5 var(--font-mono);
    tab-size: 4;
}
.editor.revealed { min-height: 12rem; margin-bottom: 1rem; background: var(--surface); }

/* Field labels in the brand's uppercase caption style. */
.field, .options label {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    margin-bottom: 1.25rem;
    font: 400 .875rem/1.3 var(--font-sans);
    text-transform: uppercase;
    color: var(--text);
}
.field .muted, .field .small { text-transform: none; font-family: var(--font-body); }

.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; margin-top: 1.25rem; }

.check { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.check.verify { display: flex; margin: 1.25rem 0; font-weight: 500; }

input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--check-accent); margin: 0; flex-shrink: 0; }

.copy-row { display: flex; gap: .5rem; }

.error { color: var(--error-text); font-size: .9rem; display: block; margin: .5rem 0; }

/* ---------- timer ---------- */

.timer { border: 0; margin: 1.25rem 0; padding: 1rem 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
.timer legend {
    float: left;
    width: 100%;
    padding: 0;
    margin-bottom: .25rem;
    font: 400 .875rem/1.3 var(--font-sans);
    text-transform: uppercase;
}
.timer-inputs { display: flex; gap: .5rem; }
.timer-inputs .timer-amount { width: 6rem; }
.timer-inputs .timer-unit { width: auto; }
.timer .muted { font-size: .875rem; }

.countdown time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.countdown time.expired { color: var(--noa-error); }

/* ---------- buttons (noaignite.com "button-contained" / "button-outlined") ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font: 400 1rem/1.3 var(--font-sans);
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--strong-border);
    border-radius: var(--radius);
    padding: .5rem 1rem;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--outline-hover-bg); border-color: var(--outline-hover-bg); color: var(--outline-hover-text); }

.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-text); padding: 14px 1.25rem; }
.btn.primary:hover { background: var(--btn-hover-bg); border-color: var(--btn-hover-bg); color: var(--btn-hover-text); }

.btn.danger { background: var(--noa-error); border-color: var(--noa-error); color: var(--noa-white); padding: 14px 1.25rem; }
.btn.danger:hover { background: var(--noa-dark); border-color: var(--noa-dark); }

.btn:disabled, .btn:disabled:hover {
    cursor: not-allowed;
    background: var(--noa-disabled);
    border-color: var(--noa-disabled);
    color: var(--noa-white);
}

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.25rem 0 0; }
form > .btn.primary, #create-result > .btn, #request-result > .btn { margin-top: .5rem; }
#request-result .btn + .btn, #create-result .btn + .btn { margin-left: .5rem; }

/* ---------- messages ---------- */

.flash {
    background: var(--surface-alt);
    color: var(--text);
    border-left: 4px solid var(--strong-border);
    border-radius: var(--radius-input);
    padding: .9rem 1.1rem;
    margin-bottom: 1.25rem;
}
/* Warnings use the brand highlight yellow (noaignite.com uses it for <mark> and blockquote accents). */
.flash.warn { background: var(--highlight); color: var(--highlight-text); border-left-color: var(--noa-black); }
.flash.warn a { color: var(--highlight-text); }

/* ---------- share / request pages ---------- */

.share-options { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.share-option { padding: 1.25rem 1.25rem .25rem; }
.share-option h3 { margin-bottom: .25rem; }

/* Security code: the one thing people must compare, so it gets the brand's yellow highlight with a hard offset shadow. */
.fingerprint {
    display: block;
    font: 500 clamp(1.25rem, 1rem + 1.5vw, 1.75rem)/1.2 var(--font-mono);
    letter-spacing: .08em;
    text-align: center;
    text-transform: none;
    padding: 1rem;
    margin: .25rem .5rem .75rem 0;
    background: var(--highlight);
    color: var(--highlight-text);
    border-radius: var(--radius-card);
    box-shadow: .4rem .5rem 0 var(--noa-pink);
}

.request-description { font: 400 1.5rem/1.3 var(--font-serif); border-left: 4px solid var(--highlight); padding-left: 1rem; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .8rem .75rem; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.table th { font: 400 .875rem/1.3 var(--font-sans); text-transform: uppercase; color: var(--text-muted); border-bottom-color: var(--strong-border); }
.table .btn { padding: .3rem .75rem; font-size: .875rem; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
    .main { padding-block: 2rem 3rem; }
    .topbar nav { gap: .25rem 1.1rem; }
    .brand-name { display: none; }
    .copy-row { flex-direction: column; }
    .btn.primary { width: 100%; }
}
