/* =============================================================================
 * NeuraCore — the solution's shared web theme.
 * -----------------------------------------------------------------------------
 * ONE source of truth for every NeuraCore web surface. This file is not owned
 * by any single site: it lives in SubProjects/NeuraCoreWebTheme and is copied
 * into each web subproject's document root at deployment time, so two sites can
 * never drift apart visually.
 *
 * The palette is the desktop client's palette, value for value
 * (src/app/theme.rs). A user who moves from neuracore.ch to the application
 * should not feel they changed product.
 *
 * MANDATORY RULE, INHERITED FROM AGENTS.md
 *   Text drawn on the cyan accent — or on any light accent fill — is ALWAYS
 *   dark (--nc-on-accent). Light text on cyan is unreadable. Every component
 *   below that fills with an accent sets its own foreground; nothing relies on
 *   inheritance to get this right.
 *
 * Sections
 *   1. Tokens
 *   2. Reset and base
 *   3. Typography
 *   4. Layout
 *   5. Surfaces
 *   6. Controls
 *   7. Forms
 *   8. Tables
 *   9. Status and badges
 *  10. Navigation
 *  11. Motion and responsiveness
 * ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */
:root {
    /* Palette — identical to the desktop client. */
    --nc-cyan:        #22c3c3;
    --nc-cyan-dim:    #199a9a;
    --nc-cyan-glow:   rgba(34, 195, 195, 0.28);
    --nc-purple:      #b07cf7;
    --nc-orange:      #ff8c00;
    --nc-yellow:      #ffd700;
    --nc-green:       #4caf50;
    --nc-red:         #f44336;

    --nc-bg:          #121214;
    --nc-panel:       #1e1e22;
    --nc-panel-high:  #26262c;
    --nc-line:        #33333c;
    --nc-line-soft:   #2a2a31;

    --nc-text:        #e2e8f0;
    --nc-text-dim:    #9aa3b2;
    --nc-text-faint:  #6b7280;
    --nc-on-accent:   #121214;

    /* Type. A system stack: no webfont request, no third-party origin, and
       therefore nothing to add to the Content-Security-Policy. */
    --nc-font: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --nc-font-mono: "JetBrains Mono", "Fira Mono", "SFMono-Regular", Consolas, monospace;

    --nc-size-xs:   0.75rem;
    --nc-size-sm:   0.875rem;
    --nc-size-base: 1rem;
    --nc-size-lg:   1.25rem;
    --nc-size-xl:   1.75rem;
    --nc-size-2xl:  2.5rem;
    --nc-size-3xl:  3.5rem;

    /* Space, on a 4px grid. */
    --nc-space-1: 0.25rem;
    --nc-space-2: 0.5rem;
    --nc-space-3: 0.75rem;
    --nc-space-4: 1rem;
    --nc-space-6: 1.5rem;
    --nc-space-8: 2rem;
    --nc-space-12: 3rem;
    --nc-space-16: 4rem;
    --nc-space-24: 6rem;

    --nc-radius-sm: 6px;
    --nc-radius:    10px;
    --nc-radius-lg: 16px;
    --nc-radius-pill: 999px;

    --nc-shadow:      0 8px 24px rgba(0, 0, 0, 0.45);
    --nc-shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.30);

    --nc-measure: 68ch;   /* Comfortable reading width. */
    --nc-page:    1160px; /* Content column maximum. */

    --nc-transition: 140ms ease;
}

/* --- 2. Reset and base --------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
    /* The one place a percentage is used: it honours a reader who has changed
       their browser's base size, which a px root would silently override. */
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--nc-bg);
    color: var(--nc-text);
    font-family: var(--nc-font);
    font-size: var(--nc-size-base);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

hr {
    border: 0;
    border-top: 1px solid var(--nc-line);
    margin: var(--nc-space-8) 0;
}

::selection { background: var(--nc-cyan); color: var(--nc-on-accent); }

/* A visible focus ring everywhere. Removing it would make the whole site
   unusable by keyboard, which is an accessibility failure, not a style. */
:focus-visible {
    outline: 2px solid var(--nc-cyan);
    outline-offset: 2px;
    border-radius: var(--nc-radius-sm);
}

/* --- 3. Typography ------------------------------------------------------- */
h1, h2, h3, h4 {
    margin: 0 0 var(--nc-space-4);
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.015em;
    color: #fff;
}

h1 { font-size: var(--nc-size-2xl); }
h2 { font-size: var(--nc-size-xl); }
h3 { font-size: var(--nc-size-lg); }
h4 { font-size: var(--nc-size-base); }

p { margin: 0 0 var(--nc-space-4); max-width: var(--nc-measure); }

a {
    color: var(--nc-cyan);
    text-decoration: none;
    transition: color var(--nc-transition);
}
a:hover { color: #6fe3e3; text-decoration: underline; }

code, kbd, pre, samp { font-family: var(--nc-font-mono); font-size: 0.92em; }

code {
    background: var(--nc-panel-high);
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius-sm);
    padding: 0.1em 0.4em;
    color: var(--nc-cyan);
}

pre {
    background: var(--nc-panel);
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius);
    padding: var(--nc-space-4);
    /* Wide content scrolls inside its own box; the page body never scrolls
       sideways. */
    overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; color: var(--nc-text); }

.nc-lead {
    font-size: var(--nc-size-lg);
    color: var(--nc-text-dim);
    max-width: var(--nc-measure);
}
.nc-dim   { color: var(--nc-text-dim); }
.nc-faint { color: var(--nc-text-faint); }
.nc-mono  { font-family: var(--nc-font-mono); }
.nc-nowrap { white-space: nowrap; }

.nc-eyebrow {
    display: inline-block;
    font-size: var(--nc-size-xs);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--nc-cyan);
    margin-bottom: var(--nc-space-3);
}

/* Screen-reader-only. Used for form labels a sighted user reads from context. */
.nc-sr {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- 4. Layout ----------------------------------------------------------- */
.nc-page {
    width: 100%;
    max-width: var(--nc-page);
    margin-inline: auto;
    padding-inline: var(--nc-space-6);
}

.nc-section { padding-block: var(--nc-space-24); }
.nc-section--tight { padding-block: var(--nc-space-12); }

.nc-grid { display: grid; gap: var(--nc-space-6); }
.nc-grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.nc-grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.nc-grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.nc-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nc-space-3);
}
.nc-row--between { justify-content: space-between; }
.nc-row--end { justify-content: flex-end; }

.nc-stack > * + * { margin-top: var(--nc-space-4); }

/* --- 5. Surfaces --------------------------------------------------------- */
.nc-card {
    background: var(--nc-panel);
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius-lg);
    padding: var(--nc-space-6);
    box-shadow: var(--nc-shadow-soft);
    transition: border-color var(--nc-transition), transform var(--nc-transition);
}
.nc-card--hover:hover {
    border-color: var(--nc-cyan-dim);
    transform: translateY(-2px);
}
.nc-card h3 { margin-bottom: var(--nc-space-2); }
.nc-card p:last-child { margin-bottom: 0; }

.nc-panel {
    background: var(--nc-panel);
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius);
    padding: var(--nc-space-6);
}

/* A short rule of cyan used to head a block. */
.nc-rule {
    width: 48px;
    height: 3px;
    border-radius: var(--nc-radius-pill);
    background: var(--nc-cyan);
    margin-bottom: var(--nc-space-4);
}

/* The glow that gives the dark surfaces depth. Purely decorative, so it is
   marked aria-hidden wherever it is used and never carries content. */
.nc-glow {
    position: absolute;
    inset: auto;
    width: 520px; height: 520px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--nc-cyan-glow) 0%, transparent 68%);
    filter: blur(28px);
    pointer-events: none;
    z-index: 0;
}

/* --- 6. Controls --------------------------------------------------------- */
.nc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--nc-space-2);
    padding: 0.65rem 1.35rem;
    border-radius: var(--nc-radius-pill);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: var(--nc-size-sm);
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--nc-transition), color var(--nc-transition),
                border-color var(--nc-transition), transform var(--nc-transition);
}
.nc-btn:hover { text-decoration: none; transform: translateY(-1px); }
.nc-btn:active { transform: translateY(0); }
.nc-btn:disabled,
.nc-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Filled with the accent, so the label is dark. See the mandatory rule above. */
.nc-btn--primary {
    background: var(--nc-cyan);
    color: var(--nc-on-accent);
}
.nc-btn--primary:hover { background: #4ad6d6; color: var(--nc-on-accent); }

.nc-btn--ghost {
    background: transparent;
    color: var(--nc-text);
    border-color: var(--nc-line);
}
.nc-btn--ghost:hover { border-color: var(--nc-cyan); color: var(--nc-cyan); }

/* Destructive actions are red-filled; red is dark enough for light text. */
.nc-btn--danger {
    background: var(--nc-red);
    color: #fff;
}
.nc-btn--danger:hover { background: #ff6054; color: #fff; }

.nc-btn--sm { padding: 0.35rem 0.85rem; font-size: var(--nc-size-xs); }
.nc-btn--block { display: flex; width: 100%; }

/* --- 7. Forms ------------------------------------------------------------ */
.nc-field { display: block; margin-bottom: var(--nc-space-4); }

.nc-label {
    display: block;
    font-size: var(--nc-size-sm);
    font-weight: 600;
    color: var(--nc-text-dim);
    margin-bottom: var(--nc-space-2);
}

.nc-input,
.nc-select,
.nc-textarea {
    /* A finite width, always. A control that asks for more room than its
       parent has is what makes a layout grow every reflow. */
    width: 100%;
    max-width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--nc-bg);
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius-sm);
    color: var(--nc-text);
    font: inherit;
    font-size: var(--nc-size-sm);
    transition: border-color var(--nc-transition), box-shadow var(--nc-transition);
}
.nc-input:focus,
.nc-select:focus,
.nc-textarea:focus {
    border-color: var(--nc-cyan);
    box-shadow: 0 0 0 3px var(--nc-cyan-glow);
    outline: none;
}
.nc-input::placeholder { color: var(--nc-text-faint); }
.nc-input:disabled { opacity: 0.5; cursor: not-allowed; }
.nc-textarea { min-height: 6rem; resize: vertical; }

.nc-hint {
    display: block;
    margin-top: var(--nc-space-2);
    font-size: var(--nc-size-xs);
    color: var(--nc-text-faint);
}

.nc-check {
    display: inline-flex;
    align-items: center;
    gap: var(--nc-space-2);
    cursor: pointer;
    font-size: var(--nc-size-sm);
}
.nc-check input { accent-color: var(--nc-cyan); width: 1rem; height: 1rem; }

/* --- 8. Tables ----------------------------------------------------------- */
/* The wrapper is what scrolls. A wide table must never widen the document. */
.nc-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius);
    background: var(--nc-panel);
}

.nc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--nc-size-sm);
}
.nc-table th,
.nc-table td {
    padding: var(--nc-space-3) var(--nc-space-4);
    text-align: left;
    border-bottom: 1px solid var(--nc-line-soft);
    vertical-align: middle;
}
.nc-table th {
    font-size: var(--nc-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--nc-text-dim);
    background: var(--nc-panel-high);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.nc-table tbody tr:last-child td { border-bottom: 0; }
.nc-table tbody tr:hover { background: rgba(34, 195, 195, 0.05); }
.nc-table td.nc-num { text-align: right; font-family: var(--nc-font-mono); }

.nc-empty {
    padding: var(--nc-space-12) var(--nc-space-6);
    text-align: center;
    color: var(--nc-text-faint);
}

/* --- 9. Status and badges ------------------------------------------------ */
.nc-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--nc-space-1);
    padding: 0.15rem 0.6rem;
    border-radius: var(--nc-radius-pill);
    font-size: var(--nc-size-xs);
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
/* Every one of these is a light fill, so every one of them sets dark text. */
.nc-badge--cyan   { background: var(--nc-cyan);   color: var(--nc-on-accent); }
.nc-badge--green  { background: var(--nc-green);  color: var(--nc-on-accent); }
.nc-badge--orange { background: var(--nc-orange); color: var(--nc-on-accent); }
.nc-badge--yellow { background: var(--nc-yellow); color: var(--nc-on-accent); }
.nc-badge--purple { background: var(--nc-purple); color: var(--nc-on-accent); }
.nc-badge--red    { background: var(--nc-red);    color: #fff; }
.nc-badge--muted  {
    background: transparent;
    color: var(--nc-text-dim);
    border: 1px solid var(--nc-line);
}

/* The release tag every web surface carries in its footer. A muted outline
   rather than an accent fill: it is a fact somebody looks for deliberately when
   reporting a problem, never something the page needs to draw attention to. The
   tabular figures stop 1.0.0 and 1.10.0 from shifting the badge's width. */
.nc-version {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.nc-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}
.nc-dot--on  { background: #8bd97c; box-shadow: 0 0 6px #8bd97c; }
.nc-dot--off { background: #ef5350; }

.nc-notice {
    border-radius: var(--nc-radius);
    padding: var(--nc-space-3) var(--nc-space-4);
    border: 1px solid;
    font-size: var(--nc-size-sm);
    margin-bottom: var(--nc-space-4);
}
.nc-notice p:last-child { margin-bottom: 0; }
.nc-notice--info    { border-color: var(--nc-cyan);   background: rgba(34, 195, 195, 0.09); }
.nc-notice--ok      { border-color: var(--nc-green);  background: rgba(76, 175, 80, 0.10); }
.nc-notice--warn    { border-color: var(--nc-orange); background: rgba(255, 140, 0, 0.10); }
.nc-notice--error   { border-color: var(--nc-red);    background: rgba(244, 67, 54, 0.10); }

/* --- 10. Navigation ------------------------------------------------------ */
.nc-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--nc-space-3);
    font-weight: 700;
    font-size: var(--nc-size-lg);
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
}
.nc-brand:hover { color: #fff; text-decoration: none; }
.nc-brand__mark {
    width: 32px; height: 32px;
    flex: 0 0 auto;
}
.nc-brand__core { color: var(--nc-cyan); }

/* A vertical tab strip: the admin console's navigation, and the same shape as
   the desktop tools' left-hand strip. */
.nc-vtabs {
    display: flex;
    flex-direction: column;
    gap: var(--nc-space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}
.nc-vtab {
    display: flex;
    align-items: center;
    gap: var(--nc-space-3);
    padding: 0.6rem 0.9rem;
    border-radius: var(--nc-radius-sm);
    color: var(--nc-text-dim);
    font-size: var(--nc-size-sm);
    font-weight: 600;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background var(--nc-transition), color var(--nc-transition);
}
.nc-vtab:hover {
    background: var(--nc-panel-high);
    color: var(--nc-text);
    text-decoration: none;
}
/* The selected tab is a cyan fill, so its label is dark. */
.nc-vtab--active,
.nc-vtab--active:hover {
    background: var(--nc-cyan);
    color: var(--nc-on-accent);
    border-left-color: var(--nc-cyan);
}

/* Pagination, shared by every browser in the console. */
.nc-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nc-space-1);
    margin-top: var(--nc-space-4);
}
.nc-pager__link {
    min-width: 2.25rem;
    padding: 0.3rem 0.6rem;
    text-align: center;
    border: 1px solid var(--nc-line);
    border-radius: var(--nc-radius-sm);
    color: var(--nc-text-dim);
    font-size: var(--nc-size-sm);
    text-decoration: none;
}
.nc-pager__link:hover { border-color: var(--nc-cyan); color: var(--nc-cyan); text-decoration: none; }
.nc-pager__link--current {
    background: var(--nc-cyan);
    border-color: var(--nc-cyan);
    color: var(--nc-on-accent);
    font-weight: 700;
}
.nc-pager__link--disabled {
    opacity: 0.35;
    pointer-events: none;
}
.nc-pager__gap { padding: 0.3rem 0.2rem; color: var(--nc-text-faint); }

/* --- 11. Motion and responsiveness --------------------------------------- */
@keyframes nc-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}
.nc-rise { animation: nc-rise 520ms ease both; }
.nc-rise-2 { animation-delay: 90ms; }
.nc-rise-3 { animation-delay: 180ms; }
.nc-rise-4 { animation-delay: 270ms; }

@keyframes nc-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}
.nc-pulse { animation: nc-pulse 2.4s ease-in-out infinite; }

/* A reader who has asked for less movement gets none of it. */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 860px) {
    :root {
        --nc-size-2xl: 2rem;
        --nc-size-3xl: 2.5rem;
        --nc-space-24: 4rem;
    }
    .nc-page { padding-inline: var(--nc-space-4); }
}

/* Printing an operator listing is a real thing someone does with a console. */
@media print {
    body { background: #fff; color: #000; }
    .nc-no-print { display: none !important; }
    .nc-table-wrap { border-color: #999; }
}
