/* Shared look for every osrs.lol page: colour tokens for both themes, the site header and footer,
   buttons, form controls and article text. Page-specific styles stay in each page's <style> block.
   Colours are hex because the dashboard hands some of them to Chart.js, which can't read oklch(). */

:root {
    /* Dark theme (default): the site's original warm charcoal colours */
    --bg-dark: #211e1c;          /* page */
    --bg-main: #3a3532;          /* cards */
    --bg-contrast: #2a2725;      /* insets, table rows, inputs */
    --border-color: #504a45;     /* card and divider lines */
    --border-strong: #8a8077;    /* form field outlines (3:1 against cards) */
    --text-primary: #e5e0db;
    --text-secondary: #a8a29e;
    --text-muted: #9a928b;
    --accent-gold: #e3b415;          /* was #e7bc1c before 2026-11-11 A/B test */
    --accent-gold-hover: #f2cd45;
    --text-on-accent: #1c1917;
    --accent-green: #22c55e;
    --accent-red: #fb8585;       /* a touch lighter than the old #ef4444 so it's readable on cards */
    --accent-blue: #60a5fa;
    --chart-red: #ef4444;        /* the chart and market table keep the original red and blue */
    --chart-blue: #3b82f6;
    --focus-ring: #e3b415;
    --chart-grid-color: rgba(229, 224, 219, 0.1);
    --chart-bg: #252220;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

html[data-theme="light"] {
    /* Light theme: warm paper with low-saturation browns, so it is calm to read for long sessions */
    --bg-dark: #f4f0e8;
    --bg-main: #fbf9f5;
    --bg-contrast: #ece6db;
    --border-color: #ddd4c5;
    --border-strong: #9a8c78;
    --text-primary: #352d27;
    --text-secondary: #5f554b;
    --text-muted: #6b6156;
    --accent-gold: #8a5d00;
    --accent-gold-hover: #734d00;
    --text-on-accent: #fffaf0;
    --accent-green: #17723f;
    --accent-red: #b42318;
    --accent-blue: #1d5fc4;
    --chart-red: #b42318;
    --chart-blue: #1d5fc4;
    --focus-ring: #8a5d00;
    --chart-grid-color: rgba(53, 45, 39, 0.08);
    --chart-bg: rgba(53, 45, 39, 0.03);
    --shadow-card: 0 1px 2px rgba(53, 45, 39, 0.06), 0 1px 1px rgba(53, 45, 39, 0.04);
    --shadow-pop: 0 8px 24px rgba(53, 45, 39, 0.14);
    color-scheme: light;
}

html,
body {
    overflow-x: clip;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    /* Segoe UI ships with Windows; other devices fall back to their own interface font */
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
}

/* ---------- Colour helpers used across pages and by build.js ---------- */
.bg-main { background-color: var(--bg-main); }
.bg-dark-contrast { background-color: var(--bg-contrast); }
.border-custom { border-color: var(--border-color); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-gold); }
.text-profit { color: var(--accent-green); }
.text-loss { color: var(--accent-red); }
.text-volume { color: var(--accent-blue); }
.section-title { color: var(--text-primary); }
.placeholder-custom::placeholder { color: var(--text-muted); opacity: 1; }

.card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}

/* ---------- Focus: one visible ring for every control, shown instantly ---------- */
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Inputs show the ring on any focus, since typing is what they're for */
html .field:focus,
html .field:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
    border-color: var(--accent-gold);
}

a.link,
.link {
    color: var(--accent-gold);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a.link:hover {
    color: var(--accent-gold-hover);
}

/* ---------- Site header: the original centred banner (coins, Cinzel title with a soft glow, subtitle)
   with the theme switch in the top-right corner ---------- */
.site-header {
    position: relative;
    margin-bottom: 32px;
    text-align: center;
}

.site-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.site-coin {
    height: 48px;
    width: auto;
    flex-shrink: 0;
}

.site-coin-flip {
    transform: scaleX(-1);
}

.main-title {
    display: inline-block;
    color: var(--accent-gold);
    text-decoration: none;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(227, 180, 21, 0.15);
    transition: all 0.3s ease-in-out;
}

.main-title:hover {
    filter: brightness(1.15);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), 0 2px 16px rgba(227, 180, 21, 0.3);
    transform: scale(1.02);
}

/* The dark glow smudges dark text on the light theme, so light mode keeps the gold without it */
html[data-theme="light"] .main-title,
html[data-theme="light"] .main-title:hover {
    text-shadow: none;
}

.site-title {
    margin-bottom: 8px;
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 700;
    /* 2.25rem on desktop as before, scaling down on tablets and phones so it doesn't break into many lines */
    font-size: clamp(1.375rem, 0.9rem + 2.2vw, 2.25rem);
    line-height: 1.2;
}

.site-tagline {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.site-tagline svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.site-header .theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
}

/* Phones: drop the side coins and leave room for the theme switch so the title stays to a few lines */
@media (max-width: 639px) {
    .site-header { margin-bottom: 24px; }
    .site-coin { display: none; }
    .site-title { padding: 0 44px; }
    .site-tagline { display: block; font-size: 0.9375rem; line-height: 1.5rem; }
    .site-tagline svg { display: none; }
}

html .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-primary);
}

html .theme-toggle:hover {
    background-color: var(--bg-contrast);
}

html .theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* The icon shows the theme you would switch to: a sun in dark mode, a moon in light mode */
html .theme-toggle .icon-moon,
html[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

html[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

/* ---------- Page headings ---------- */
.page-title {
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.75rem, 1.25rem + 2vw, 2.5rem);
    line-height: 1.15;
    letter-spacing: 0.01em;
    color: var(--accent-gold);
    overflow-wrap: anywhere;
    min-width: 0;
}

.page-lead {
    margin-top: 8px;
    max-width: 62ch;
    color: var(--text-secondary);
    font-size: 1.0625rem;
}

/* ---------- Buttons ---------- */
html .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms cubic-bezier(0.2, 0, 0, 1), border-color 150ms cubic-bezier(0.2, 0, 0, 1), color 150ms cubic-bezier(0.2, 0, 0, 1);
}

html .btn:hover {
    background-color: var(--bg-contrast);
}

html .btn:active {
    transform: translateY(1px);
}

html .btn[aria-pressed="true"] {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

html .btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

html .btn-primary {
    background-color: var(--accent-gold);
    border-color: var(--accent-gold);
    color: var(--text-on-accent);
}

html .btn-primary:hover {
    background-color: var(--accent-gold-hover);
    border-color: var(--accent-gold-hover);
}

html .btn-primary:disabled {
    background-color: var(--accent-gold);
}

html .btn-sm {
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.875rem;
}

html .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    color: var(--text-secondary);
    background: transparent;
}

html .icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-contrast);
}

/* Segmented control (timeframe picker): the original look, separate rectangular buttons that fill gold
   when picked or hovered */
.segmented {
    display: inline-flex;
    gap: 8px;
    padding: 4px;
    border-radius: 8px;
    background-color: var(--bg-contrast);
}

html .segmented button {
    padding: 4px 16px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

html .segmented button:hover,
html .segmented button.active,
html .segmented button[aria-pressed="true"] {
    background-color: var(--accent-gold);
    border-color: var(--accent-gold);
    color: var(--text-on-accent);
}

/* ---------- Form fields ---------- */
html .field {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background-color: var(--bg-contrast);
    color: var(--text-primary);
    padding: 8px 10px;
}

html .field::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

html input[type="checkbox"].field {
    width: 16px;
    height: 16px;
    padding: 0;
    accent-color: var(--accent-gold);
}

/* ---------- Article text (guide, acknowledgements) ---------- */
.prose-site {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.prose-site h2 {
    margin-top: 2.25rem;
    margin-bottom: 0.75rem;
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

.prose-site h2:first-child { margin-top: 0; }

.prose-site p { margin-bottom: 1rem; }

.prose-site ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin-bottom: 1.25rem;
}

.prose-site li { margin-bottom: 0.5rem; }

.prose-site strong { font-weight: 700; }

.prose-site a:not(.btn) {
    color: var(--accent-gold);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.prose-site a:not(.btn):hover { color: var(--accent-gold-hover); }

/* ---------- Site footer ---------- */
.site-footer {
    margin-top: 56px;
    padding: 24px 0 32px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    margin-bottom: 12px;
}

.site-footer nav a {
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.site-footer nav a:hover {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.site-footer p + p { margin-top: 4px; }

.site-footer a.link { color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Tailwind's .hidden must still win over the component display values above */
.hidden {
    display: none !important;
}
