/*
 * ITRAINDB themes — Dark and Train.
 *
 * Light is the site as built and needs no stylesheet; header.php loads this
 * file only on a themed page (a logged-in user's app theme, or a public
 * profile's own theme) and puts class="themed theme-<name>" on <body>.
 *
 * The pages are written in Tailwind slate utilities (bg-white,
 * text-slate-900, ...). Rather than touch that markup, the rules below
 * re-point those utilities at a handful of variables whenever they sit
 * inside .themed, and each theme only has to define the variables. A
 * ".themed .x" selector outranks Tailwind's own ".x", so no !important.
 *
 * Adding a theme: add its key to THEMES in includes/themes.php and a
 * .theme-<key> block of variables here.
 *
 * A public profile's "Custom" theme (class theme-custom) has no block here:
 * its variables are worked out from the owner's four colours by
 * theme_custom_css() in includes/themes.php and printed into the page.
 */

/* ---- Dark: the same slate family, inverted ------------------------------ */
.theme-dark {
    --t-page: #0f172a;        /* page background */
    --t-card: #1e293b;        /* cards, menus, popups */
    --t-sunken: #172033;      /* insets inside a card, form fields */
    --t-hover: #334155;       /* hover wash, small chips */
    --t-track: #334155;       /* the empty part of a bar */
    --t-strong: #e2e8f0;      /* bar fills and primary buttons */
    --t-strong-hover: #cbd5e1;
    --t-on-strong: #0f172a;   /* text on --t-strong */
    --t-ink-1: #f1f5f9;       /* headings, figures */
    --t-ink-2: #cbd5e1;       /* body text */
    --t-ink-3: #94a3b8;       /* secondary text */
    --t-ink-4: #8191a8;       /* small labels */
    --t-ink-5: #475569;       /* disabled */
    --t-line: #334155;        /* hairlines */
    --t-line-2: #475569;      /* field and button outlines */
    --t-red: #f87171;
    --t-blue: #60a5fa;
    --t-purple: #c084fc;
    --t-hero-from: #334155;
    --t-hero-to: #020617;
}

/* ---- Train: Pullman green coachwork with gold-leaf lining ----------------- */
.theme-train {
    --t-page: #18261f;
    --t-card: #22372c;
    --t-sunken: #1c2e25;
    --t-hover: #2f4a3b;
    --t-track: #34513f;
    --t-strong: #d9b25a;      /* gold leaf */
    --t-strong-hover: #e7c777;
    --t-on-strong: #18261f;
    --t-ink-1: #f6eed8;       /* ivory lettering */
    --t-ink-2: #e2dac1;
    --t-ink-3: #b7b8a0;
    --t-ink-4: #96a391;
    --t-ink-5: #5d7566;
    --t-line: #375342;
    --t-line-2: #4f705c;
    --t-red: #f2907a;         /* signal lamp */
    --t-blue: #93c5e8;
    --t-purple: #d2aeea;
    --t-hero-from: #2f4a3b;
    --t-hero-to: #101a15;
}

/* ---- Shared rules ------------------------------------------------------- */
/* body carries its own Tailwind colours, so this needs the extra weight. */
body.themed {
    background-color: var(--t-page);
    color: var(--t-ink-2);
    color-scheme: dark;   /* native checkboxes, date pickers and scrollbars follow */
}
/* Tailwind gives every border a light gray by default. */
.themed *, .themed ::before, .themed ::after { border-color: var(--t-line); }
.themed .bg-white { background-color: var(--t-card); }
.themed .bg-slate-50 { background-color: var(--t-sunken); }
.themed .bg-slate-100 { background-color: var(--t-hover); }
.themed .bg-slate-200,
.themed .bg-slate-300 { background-color: var(--t-track); }
.themed .bg-slate-600,
.themed .bg-slate-700,
.themed .bg-slate-800,
.themed .bg-slate-900 { background-color: var(--t-strong); }
.themed .hover\:bg-slate-50:hover,
.themed .hover\:bg-slate-100:hover,
.themed .hover\:bg-slate-200:hover { background-color: var(--t-hover); }
.themed .hover\:bg-slate-700:hover,
.themed .hover\:bg-slate-800:hover { background-color: var(--t-strong-hover); }
.themed .bg-slate-600.text-white,
.themed .bg-slate-700.text-white,
.themed .bg-slate-800.text-white,
.themed .bg-slate-900.text-white { color: var(--t-on-strong); }
.themed .text-slate-900,
.themed .text-slate-800 { color: var(--t-ink-1); }
.themed .text-slate-700 { color: var(--t-ink-2); }
.themed .text-slate-600,
.themed .text-slate-500 { color: var(--t-ink-3); }
.themed .text-slate-400 { color: var(--t-ink-4); }
.themed .text-slate-300 { color: var(--t-ink-5); }
.themed .hover\:text-slate-900:hover,
.themed .hover\:text-slate-800:hover,
.themed .hover\:text-slate-700:hover { color: var(--t-ink-1); }
.themed .text-red-700,
.themed .text-red-600 { color: var(--t-red); }
.themed .text-blue-600 { color: var(--t-blue); }
.themed .text-purple-600 { color: var(--t-purple); }
.themed .border-slate-100,
.themed .border-slate-200 { border-color: var(--t-line); }
.themed .border-slate-300,
.themed .border-slate-400 { border-color: var(--t-line-2); }
.themed .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
.themed .divide-slate-200 > :not([hidden]) ~ :not([hidden]) { border-color: var(--t-line); }
.themed .ring-white { --tw-ring-color: var(--t-card); }
.themed .focus\:ring-slate-400:focus,
.themed .focus\:ring-slate-500:focus { --tw-ring-color: var(--t-ink-3); }

/* The profile banner: a gradient from one theme tone to another. */
.themed .from-slate-700 {
    --tw-gradient-from: var(--t-hero-from);
    --tw-gradient-to: transparent;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.themed .to-slate-900 { --tw-gradient-to: var(--t-hero-to); }

/* Form fields. */
.themed select, .themed textarea,
.themed input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="color"]) {
    background-color: var(--t-sunken);
    color: var(--t-ink-1);
    border-color: var(--t-line-2);
}
.themed .placeholder\:text-slate-400::placeholder { color: var(--t-ink-4); }
.themed .focus\:border-slate-500:focus, .themed .hover\:border-slate-400:hover { border-color: var(--t-ink-3); }
.themed .disabled\:bg-slate-50:disabled { background-color: var(--t-page); }
.themed .disabled\:text-slate-300:disabled { color: var(--t-ink-5); }
/* File pickers ("Choose file" buttons). */
.themed .file\:bg-slate-100::file-selector-button { background-color: var(--t-hover); }
.themed .file\:text-slate-700::file-selector-button { color: var(--t-ink-1); }
.themed .hover\:file\:bg-slate-200:hover::file-selector-button { background-color: var(--t-track); }

/* Selected states that are drawn with the darkest slate on a light page. */
.themed .border-slate-900, .themed .has-\[\:checked\]\:border-slate-900:has(:checked) { border-color: var(--t-strong); }
.themed .has-\[\:checked\]\:ring-slate-900:has(:checked) { --tw-ring-color: var(--t-strong); }
.themed .ring-slate-200, .themed .hover\:ring-slate-300:hover { --tw-ring-color: var(--t-line-2); }
.themed .hover\:bg-slate-300:hover { background-color: var(--t-hover); }
.themed .hover\:text-slate-600:hover { color: var(--t-ink-1); }
/* Underlined links. */
.themed .decoration-slate-300 { text-decoration-color: var(--t-line-2); }
.themed .hover\:decoration-slate-900:hover { text-decoration-color: var(--t-ink-1); }
.themed .hover\:outline-slate-900:hover { outline-color: var(--t-ink-1); }
/* Translucent white panels. */
.themed .bg-white\/90 { background-color: color-mix(in srgb, var(--t-card) 90%, transparent); }

/* The site logo and the brand logos are drawn for a white page (several
   have a solid white background), so they sit on a small white plate. */
.themed header img[alt="ITRAINDB"] { background: #ffffff; border-radius: 6px; padding: 2px 6px; }
.themed img[src*="/brand_logos/"] { background: #ffffff; border-radius: 3px; padding: 1px 3px; }

/* Status colours (saved / error / warning / info messages and badges) were
   tuned for white: here each becomes a tint of the card with lighter text. */
.themed .bg-amber-50, .themed .bg-amber-100 { background-color: color-mix(in srgb, #f59e0b 16%, var(--t-card)); }
.themed .text-amber-800 { color: #fcd34d; }
.themed .border-amber-200, .themed .border-amber-300 { border-color: color-mix(in srgb, #f59e0b 40%, var(--t-card)); }
.themed .bg-green-50, .themed .bg-green-100 { background-color: color-mix(in srgb, #22c55e 16%, var(--t-card)); }
.themed .text-green-600, .themed .text-green-700, .themed .text-green-800 { color: #86efac; }
.themed .border-green-200 { border-color: color-mix(in srgb, #22c55e 40%, var(--t-card)); }
.themed .bg-red-50, .themed .hover\:bg-red-50:hover { background-color: color-mix(in srgb, #ef4444 16%, var(--t-card)); }
.themed .border-red-200, .themed .border-red-300 { border-color: color-mix(in srgb, #ef4444 45%, var(--t-card)); }
.themed .hover\:text-red-600:hover { color: var(--t-red); }
.themed .bg-blue-50 { background-color: color-mix(in srgb, #3b82f6 16%, var(--t-card)); }
.themed .border-blue-200 { border-color: color-mix(in srgb, #3b82f6 40%, var(--t-card)); }
.themed .text-blue-700 { color: var(--t-blue); }

/* ---- Train only ----------------------------------------------------------- */
/* Railroad-roman lettering for headings; the figures keep the site's sans. */
.theme-train h1, .theme-train h2, .theme-train h3 {
    font-family: Rockwell, "Rockwell Nova", "Roboto Slab", "DejaVu Serif", Georgia, serif;
    letter-spacing: 0.01em;
}
/* (.themed.theme-train: enough weight to beat the heading's own text-slate class) */
.themed.theme-train h1 { color: var(--t-strong); }

/* Coach lining: a thin gold line set just inside the edge of each panel. */
.theme-train .bg-white.shadow-md {
    outline: 1px solid color-mix(in srgb, var(--t-strong) 55%, transparent);
    outline-offset: -5px;
}
/* A profile's banner (or the plain strip that stands in for one) sits inside
   that lining rather than running underneath it: 6px in from the card's top
   and sides, with corners that follow the card's own. */
.theme-train .profile-banner {
    margin: 6px 6px 0;
    width: calc(100% - 12px);
    border-radius: 6px 6px 0 0;
}

/* A length of track under the header: two rails over evenly spaced ties. */
.theme-train header::after {
    content: "";
    display: block;
    height: 11px;
    background:
        linear-gradient(#aab4b0, #aab4b0) 0 2px / 100% 2px no-repeat,
        linear-gradient(#aab4b0, #aab4b0) 0 7px / 100% 2px no-repeat,
        repeating-linear-gradient(90deg, #6b5038 0 5px, transparent 5px 15px);
    background-color: var(--t-page);
}
