/*
 * Vanguard Front design tokens + accessibility layer. Plain CSS (no build step), loaded by the game and admin layouts.
 * One place to change the look: colours, radii, focus ring. The display options (text size, contrast, motion) are driven by
 * attributes that public/js/display-prefs.js puts on <html>.
 */
:root {
    --vf-bg: #020617;
    --vf-panel: #0b1220;
    --vf-panel-2: #0f172a;
    --vf-line: #1e293b;
    --vf-text: #e2e8f0;
    --vf-muted: #94a3b8;
    --vf-accent: #22d3ee;
    --vf-good: #34d399;
    --vf-warn: #fbbf24;
    --vf-bad: #fb7185;
    --vf-violet: #a78bfa;
    --vf-radius: 14px;
    --vf-focus: #fde047;
    --vf-touch: 44px;
    color-scheme: dark;
}

/* ---- keyboard focus: always visible, same colour everywhere ------------------------------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--vf-focus);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---- skip link ---------------------------------------------------------------------------------------------- */
.vf-skip {
    position: fixed; left: 12px; top: -60px; z-index: 100000; padding: 10px 14px; border-radius: 8px;
    background: var(--vf-accent); color: #020617; font: 700 13px ui-monospace, Menlo, Consolas, monospace; text-decoration: none;
    transition: top .15s ease;
}
.vf-skip:focus { top: 12px; }

/* ---- touch targets on phones --------------------------------------------------------------------------------- */
@media (pointer: coarse) {
    button, [role="button"], select, input[type="submit"], input[type="button"] { min-height: var(--vf-touch); }
    nav a, aside a { min-height: 40px; display: inline-flex; align-items: center; }
}
@supports (padding: max(0px)) {
    body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* ---- display options (set on <html> by display-prefs.js) --------------------------------------------------- */
html[data-text="large"] { font-size: 112.5%; }
html[data-text="larger"] { font-size: 125%; }

html[data-contrast="high"] {
    --vf-muted: #e2e8f0;
    --vf-line: #64748b;
}
html[data-contrast="high"] body { color: #f8fafc; }
html[data-contrast="high"] :is(.text-slate-300, .text-slate-400, .text-slate-500, .text-slate-600) { color: #e2e8f0 !important; }
html[data-contrast="high"] :is(.border-slate-700, .border-slate-800, .border-slate-900, .border-cyan-900\/60, .border-cyan-900\/50) { border-color: #94a3b8 !important; }
html[data-contrast="high"] :is(.text-cyan-400, .text-cyan-500, .text-cyan-600) { color: #67e8f9 !important; }
html[data-contrast="high"] :is(.text-emerald-400, .text-emerald-500) { color: #6ee7b7 !important; }
html[data-contrast="high"] :is(.text-rose-400, .text-rose-500) { color: #fda4af !important; }
html[data-contrast="high"] :is(.text-amber-400, .text-amber-500) { color: #fcd34d !important; }
html[data-contrast="high"] canvas, html[data-contrast="high"] .starnova-grid::before { opacity: .5; }

html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
    html:not([data-motion="normal"]) *, html:not([data-motion="normal"]) *::before, html:not([data-motion="normal"]) *::after {
        animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
    }
}

/* ---- the display panel itself --------------------------------------------------------------------------------- */
#vfDisplayBtn {
    position: fixed; right: 12px; bottom: 56px; z-index: 40; width: 36px; height: 36px; border-radius: 50%; border: 1px solid #334155;
    background: var(--vf-panel); color: var(--vf-text); font-size: 16px; cursor: pointer; opacity: .75;
}
#vfDisplayBtn:hover, #vfDisplayBtn[aria-expanded="true"] { opacity: 1; }
#vfDisplayPanel {
    position: fixed; right: 12px; bottom: 144px; z-index: 41; width: min(290px, calc(100vw - 24px)); padding: 14px; border-radius: var(--vf-radius);
    background: var(--vf-panel); border: 1px solid #334155; color: var(--vf-text); font: 12px ui-monospace, Menlo, Consolas, monospace;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
#vfDisplayPanel[hidden] { display: none; }
#vfDisplayPanel h2 { margin: 0 0 10px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--vf-accent); }
#vfDisplayPanel .vf-row { margin: 10px 0; }
#vfDisplayPanel .vf-row > span { display: block; margin-bottom: 4px; color: var(--vf-muted); }
#vfDisplayPanel .vf-seg { display: flex; gap: 4px; }
#vfDisplayPanel .vf-seg button {
    flex: 1; padding: 6px 4px; border-radius: 8px; border: 1px solid #334155; background: #020617; color: var(--vf-text); cursor: pointer; font: inherit;
}
#vfDisplayPanel .vf-seg button[aria-pressed="true"] { border-color: var(--vf-accent); color: var(--vf-accent); background: #083344; }

/* ---- ambient music button (public/js/ambient-music.js) -------------------------------------------------------- */
#vfMusicBtn {
    position: fixed; right: 12px; bottom: 100px; z-index: 40; width: 36px; height: 36px; border-radius: 50%; border: 1px solid #334155;
    background: var(--vf-panel); color: var(--vf-text); font-size: 18px; line-height: 1; cursor: pointer;
}
#vfMusicBtn:hover { opacity: 1 !important; }
#vfMusicPop {
    position: fixed; right: 12px; bottom: 144px; z-index: 41; width: min(250px, calc(100vw - 24px)); padding: 12px; border-radius: var(--vf-radius);
    background: var(--vf-panel); border: 1px solid #334155; color: var(--vf-text); font: 12px ui-monospace, Menlo, Consolas, monospace;
}
#vfMusicPop[hidden] { display: none; }
#vfMusicPop input[type="range"] { width: 100%; margin-top: 6px; accent-color: var(--vf-accent); }
#vfMusicPop .vf-hint { margin-top: 8px; color: #64748b; }

/* Sidebar: every label stays fully readable at any width (it wraps instead of being cut off with an ellipsis). */
#tactical-sidebar nav a { flex-wrap: wrap; row-gap: 3px; column-gap: 6px; }
#tactical-sidebar nav a > div { min-width: 0; flex: 1 1 auto; }
#tactical-sidebar nav a > span { flex: 0 0 auto; margin-left: auto; }
#tactical-sidebar nav a .truncate,
#tactical-sidebar nav a span.truncate { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: break-word; line-height: 1.2; }
#tactical-sidebar nav a { line-height: 1.2; }
#tactical-sidebar { word-break: normal; overflow-wrap: break-word; }
@media (max-width: 1100px) {
    #tactical-sidebar nav a { font-size: 11.5px; padding-left: 8px; padding-right: 8px; }
}

/* The sidebar column never gets narrower than its longest label needs; the page content takes the rest. */
@media (min-width: 768px) {
    #vf-shell { grid-template-columns: clamp(196px, 21vw, 250px) minmax(0, 1fr) !important; }
    #vf-shell > #tactical-sidebar { grid-column: 1 !important; }
    #vf-shell > #main-content { grid-column: 2 / -1 !important; }
}

/* Cosmetic interface accents (bought in the Cosmetics shop): they recolour the header, the sidebar and page titles only. */
html[data-vf-accent="ember"] { --vf-accent: #f59e0b; }
html[data-vf-accent="verdant"] { --vf-accent: #10b981; }
html[data-vf-accent="nova"] { --vf-accent: #a855f7; }
html[data-vf-accent="ghost"] { --vf-accent: #cbd5e1; }
html[data-vf-accent] #tactical-sidebar .hud-panel,
html[data-vf-accent] header { border-color: color-mix(in srgb, var(--vf-accent) 55%, transparent) !important; box-shadow: 0 0 24px color-mix(in srgb, var(--vf-accent) 20%, transparent); }
html[data-vf-accent] #tactical-sidebar nav a[class*="bg-cyan-950"] { border-color: var(--vf-accent) !important; color: var(--vf-accent) !important; background: color-mix(in srgb, var(--vf-accent) 14%, #020617) !important; }
html[data-vf-accent] #main-content h1 { color: var(--vf-accent) !important; text-shadow: 0 0 14px color-mix(in srgb, var(--vf-accent) 45%, transparent); }

/* the floating Aa / settings buttons sit bottom-right: leave room under the page so they never cover the last lines */
#main-content { padding-bottom: 9rem; }
