/* ==========================================================================
   base.css — Reset, Typography, Spacing, Colour Tokens
   All design tokens as CSS custom properties. Rebranding requires only
   updating values here — no structural changes elsewhere.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  line-height: 1.2;
}

p {
  overflow-wrap: break-word;
}

fieldset {
  border: none;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

:root {
  /* Font families */
  --font-primary: 'Montserrat', Arial, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;

  /* Font weights */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Type scale (major third — 1.25 ratio) */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-md: 1.125rem;   /* 18px */
  --text-lg: 1.25rem;    /* 20px */
  --text-xl: 1.5rem;     /* 24px */
  --text-2xl: 1.875rem;  /* 30px */
  --text-3xl: 2.25rem;   /* 36px */
  --text-4xl: 3rem;      /* 48px */

  /* Line heights */
  --leading-tight: 1.2;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  /* Letter spacing */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* --------------------------------------------------------------------------
     Spacing Scale
     -------------------------------------------------------------------------- */

  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */

  /* --------------------------------------------------------------------------
     Border Radius
     -------------------------------------------------------------------------- */

  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */
  --radius-full: 9999px;

  /* --------------------------------------------------------------------------
     Shadows
     -------------------------------------------------------------------------- */

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* --------------------------------------------------------------------------
     Transitions
     -------------------------------------------------------------------------- */

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* --------------------------------------------------------------------------
     Layout
     -------------------------------------------------------------------------- */

  --content-width: 80rem;      /* 1280px */
  --content-narrow: 48rem;     /* 768px */
  --header-height: 4rem;       /* 64px */
  --sidebar-width: 16rem;      /* 256px */

  /* --------------------------------------------------------------------------
     Z-index Scale
     -------------------------------------------------------------------------- */

  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* --------------------------------------------------------------------------
   Accent Colour
   Per-member accent applied via inline style or class. Defaults to green.
   Applied ONLY to interactive elements — never body text or headings.
   -------------------------------------------------------------------------- */

:root {
  --colour-accent: #16a34a;
  --colour-accent-hover: #15803d;
  --colour-accent-light: #dcfce7;
  --colour-accent-subtle: rgb(22 163 74 / 0.1);
}

/* --------------------------------------------------------------------------
   Light Colour Scheme (Default)
   -------------------------------------------------------------------------- */

:root,
[data-theme="light"] {
  --colour-bg: #ffffff;
  --colour-bg-secondary: #f9fafb;
  --colour-bg-tertiary: #f3f4f6;

  --colour-surface: #f5f5f5;
  --colour-surface-hover: #eeeeee;
  --colour-surface-active: #e5e5e5;

  --colour-border: #d5d5d5;
  --colour-border-light: #dcdcdc;
  --colour-border-focus: var(--colour-accent);

  --colour-text: #111827;
  --colour-text-secondary: #4b5563;
  --colour-text-tertiary: #9ca3af;
  --colour-text-inverse: #ffffff;

  --colour-success: #16a34a;
  --colour-success-bg: #dcfce7;
  --colour-warning: #d97706;
  --colour-warning-bg: #fef3c7;
  --colour-error: #dc2626;
  --colour-error-bg: #fee2e2;
  --colour-error-subtle: rgb(220 38 38 / 0.15);
  --colour-info: #2563eb;
  --colour-info-bg: #dbeafe;

  --colour-star: #f59e0b;
  --colour-star-empty: #d1d5db;

  --colour-chrome: var(--colour-surface);

  --colour-overlay: rgb(0 0 0 / 0.5);

  --shadow-colour: rgb(0 0 0 / 0.08);
}

/* --------------------------------------------------------------------------
   Dark Colour Scheme
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --colour-bg: #141414;
    --colour-bg-secondary: #1c1c1c;
    --colour-bg-tertiary: #2a2a2a;

    --colour-surface: #1c1c1c;
    --colour-surface-hover: #2a2a2a;
    --colour-surface-active: #363636;
    --colour-surface-raised: #222222;

    --colour-border: #333333;
    --colour-border-light: #222222;
    --colour-border-focus: var(--colour-accent);

    --colour-text: #e8e8e8;
    --colour-text-secondary: #999999;
    --colour-text-tertiary: #666666;
    --colour-text-inverse: #141414;

    --colour-success: #22c55e;
    --colour-success-bg: rgb(34 197 94 / 0.15);
    --colour-warning: #f59e0b;
    --colour-warning-bg: rgb(245 158 11 / 0.15);
    --colour-error: #ef4444;
    --colour-error-bg: rgb(239 68 68 / 0.15);
    --colour-error-subtle: rgb(239 68 68 / 0.12);
    --colour-info: #3b82f6;
    --colour-info-bg: rgb(59 130 246 / 0.15);

    --colour-star: #fbbf24;
    --colour-star-empty: #444444;

    --colour-overlay: rgb(0 0 0 / 0.7);

    --shadow-colour: rgb(0 0 0 / 0.3);

    --colour-chrome: #0d0d0d;

    --colour-accent-light: rgb(22 163 74 / 0.2);
    --colour-accent-subtle: rgb(22 163 74 / 0.08);
  }
}

[data-theme="dark"] {
  --colour-bg: #141414;
  --colour-bg-secondary: #1c1c1c;
  --colour-bg-tertiary: #2a2a2a;

  --colour-surface: #1c1c1c;
  --colour-surface-hover: #2a2a2a;
  --colour-surface-active: #363636;
  --colour-surface-raised: #222222;

  --colour-border: #333333;
  --colour-border-light: #222222;
  --colour-border-focus: var(--colour-accent);

  --colour-text: #e8e8e8;
  --colour-text-secondary: #999999;
  --colour-text-tertiary: #666666;
  --colour-text-inverse: #141414;

  --colour-success: #22c55e;
  --colour-success-bg: rgb(34 197 94 / 0.15);
  --colour-warning: #f59e0b;
  --colour-warning-bg: rgb(245 158 11 / 0.15);
  --colour-error: #ef4444;
  --colour-error-bg: rgb(239 68 68 / 0.15);
  --colour-error-subtle: rgb(239 68 68 / 0.12);
  --colour-info: #3b82f6;
  --colour-info-bg: rgb(59 130 246 / 0.15);

  --colour-star: #fbbf24;
  --colour-star-empty: #444444;

  --colour-overlay: rgb(0 0 0 / 0.7);

  --shadow-colour: rgb(0 0 0 / 0.3);

  --colour-chrome: #0d0d0d;

  --colour-accent-light: rgb(22 163 74 / 0.2);
  --colour-accent-subtle: rgb(22 163 74 / 0.08);
}

/* --------------------------------------------------------------------------
   BSB Theme — Victorian Luxury (Baker Street Buds)
   Deep forest green, brass gold accents, warm cream text.
   -------------------------------------------------------------------------- */

[data-theme="bsb"] {
  --colour-bg: #1c3a18;
  --colour-bg-secondary: #22451c;
  --colour-bg-tertiary: #2a5222;

  --colour-surface: #22451c;
  --colour-surface-hover: #2a5222;
  --colour-surface-active: #335f2a;
  --colour-surface-raised: #1e3e1a;

  --colour-border: #3a6830;
  --colour-border-light: #2a5222;
  --colour-border-focus: var(--colour-accent);
  --colour-border-accent: rgba(201, 168, 76, 0.2);

  --colour-text: #e8e0d0;
  --colour-text-secondary: #a8a090;
  --colour-text-tertiary: #6a6458;
  --colour-text-inverse: #0f1f15;

  --colour-accent: #c9a84c;
  --colour-accent-hover: #b8963f;
  --colour-accent-light: rgba(201, 168, 76, 0.2);
  --colour-accent-subtle: rgba(201, 168, 76, 0.08);

  --colour-success: #4ade80;
  --colour-success-bg: rgba(74, 222, 128, 0.12);
  --colour-warning: #fbbf24;
  --colour-warning-bg: rgba(251, 191, 36, 0.12);
  --colour-error: #f87171;
  --colour-error-bg: rgba(248, 113, 113, 0.12);
  --colour-error-subtle: rgba(248, 113, 113, 0.1);
  --colour-info: #60a5fa;
  --colour-info-bg: rgba(96, 165, 250, 0.12);

  --colour-star: #c9a84c;
  --colour-star-empty: #3a5040;

  --colour-chrome: #0a1810;

  --colour-overlay: rgb(0 0 0 / 0.65);

  --shadow-colour: rgb(0 0 0 / 0.35);
}

/* --------------------------------------------------------------------------
   Global Styles
   -------------------------------------------------------------------------- */

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--colour-text);
  background-color: var(--colour-bg);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}

h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

h4 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

h5 {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}

h6 {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

/* Accent on interactive elements only */
a:hover {
  color: var(--colour-accent);
}

::selection {
  background-color: var(--colour-accent-light);
  color: var(--colour-text);
}

:focus-visible {
  outline: 2px solid var(--colour-accent);
  outline-offset: 2px;
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
