/* ==========================================================================
   Barterly — Base
   Design tokens (warm "campus notebook" palette, light / dark, accents),
   reset and typography.
   Display: Bricolage Grotesque · Accent: Instrument Serif italic · Body: Inter
   ========================================================================== */

/* ---------- Light theme: warm paper ---------- */
:root {
  color-scheme: light;

  --bg: #f4efe6;
  --bg-alt: #ece5d7;
  --surface: #fffdf8;
  --surface-2: #f8f3ea;
  --surface-3: #ebe3d4;
  --overlay: rgba(23, 21, 18, 0.55);
  --header-bg: rgba(255, 253, 248, 0.78);

  --text: #171512;
  --text-2: #3a352d;
  --muted: #6d6558;
  --muted-2: #9b9284;
  --on-primary: #ffffff;
  --ink: #171512;
  --paper: #fffdf8;

  --border: #e0d6c4;
  --border-strong: #cbbfa9;

  --success: #1f9d55;
  --success-soft: #dcf3e4;
  --warning: #e0a100;
  --danger: #d1343a;
  --star: #f2a516;

  /* Sticker colours (stay the same in both themes) */
  --sticker-yellow: #ffd23f;
  --sticker-pink: #ff9eb5;
  --sticker-green: #7ee2a8;
  --sticker-blue: #8ec5ff;
  --sticker-lilac: #c9b6ff;

  --shadow-xs: 0 1px 2px rgba(40, 30, 10, 0.06);
  --shadow-sm: 0 2px 8px rgba(40, 30, 10, 0.07);
  --shadow-md: 0 14px 34px -14px rgba(40, 30, 10, 0.22);
  --shadow-lg: 0 34px 70px -28px rgba(40, 30, 10, 0.35);
  --shadow-photo: 0 18px 40px -16px rgba(40, 30, 10, 0.45), 0 2px 6px rgba(40, 30, 10, 0.12);

  /* Accent — Barterly violet/sky from the logo (default). Overridden by [data-accent]. */
  --primary: #6a45f5;
  --primary-hover: #5633dc;
  --accent-2: #2fb6ff;

  --primary-soft: color-mix(in srgb, var(--primary) 11%, var(--surface));
  --primary-soft-2: color-mix(in srgb, var(--primary) 20%, var(--surface));
  --primary-border: color-mix(in srgb, var(--primary) 35%, var(--border));
  --primary-text: color-mix(in srgb, var(--primary) 88%, #000);
  --gradient: linear-gradient(120deg, var(--primary) 0%, var(--accent-2) 100%);
  --ring: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);

  --cat-tech: #2f6fed;
  --cat-design: #e0457b;
  --cat-language: #0f9d8a;
  --cat-business: #d98a00;
  --cat-academic: #7a4ce0;
  --cat-music: #e4572e;
  --cat-lifestyle: #2f9e44;
  --cat-more: #5c5447;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", var(--font-sans);
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-h3: 1.25rem;
  --fs-h2: clamp(2.3rem, 1.4rem + 3.6vw, 4.4rem);
  --fs-h1: clamp(3rem, 1.4rem + 7vw, 7.6rem);

  --container: 1240px;
  --gutter: clamp(16px, 4vw, 40px);
  --section-space: clamp(88px, 11vw, 160px);
  --header-h: 76px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 28px;
  --r-full: 999px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-med: 300ms;
}

/* ---------- Dark theme: warm charcoal ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12110f;
  --bg-alt: #191714;
  --surface: #1d1b18;
  --surface-2: #23211d;
  --surface-3: #2d2a25;
  --overlay: rgba(0, 0, 0, 0.7);
  --header-bg: rgba(29, 27, 24, 0.78);
  --text: #f4efe6;
  --text-2: #d8d0c2;
  --muted: #a69c8c;
  --muted-2: #716a5e;
  --ink: #f4efe6;
  --paper: #1d1b18;
  --border: #302c26;
  --border-strong: #423d34;
  --success: #4ccb7f;
  --success-soft: rgba(76, 203, 127, 0.14);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 34px 70px -24px rgba(0, 0, 0, 0.8);
  --shadow-photo: 0 18px 40px -14px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
  --primary-text: color-mix(in srgb, var(--primary) 70%, #ffffff);
  --cat-more: #a69c8c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #12110f;
    --bg-alt: #191714;
    --surface: #1d1b18;
    --surface-2: #23211d;
    --surface-3: #2d2a25;
    --overlay: rgba(0, 0, 0, 0.7);
    --header-bg: rgba(29, 27, 24, 0.78);
    --text: #f4efe6;
    --text-2: #d8d0c2;
    --muted: #a69c8c;
    --muted-2: #716a5e;
    --ink: #f4efe6;
    --paper: #1d1b18;
    --border: #302c26;
    --border-strong: #423d34;
    --success: #4ccb7f;
    --success-soft: rgba(76, 203, 127, 0.14);
    --shadow-md: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 34px 70px -24px rgba(0, 0, 0, 0.8);
    --shadow-photo: 0 18px 40px -14px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.4);
    --primary-text: color-mix(in srgb, var(--primary) 70%, #ffffff);
  }
}

/* ---------- Accent palettes ---------- */
:root[data-accent="saffron"] { --primary: #e4572e; --primary-hover: #c9431c; --accent-2: #f2b134; }
:root[data-accent="indigo"]  { --primary: #4f46e5; --primary-hover: #4338ca; --accent-2: #06b6d4; }
:root[data-accent="ocean"]   { --primary: #0b7bc4; --primary-hover: #08669f; --accent-2: #2cc5b0; }
:root[data-accent="emerald"] { --primary: #11875d; --primary-hover: #0c6e4b; --accent-2: #a3d94a; }
:root[data-accent="violet"]  { --primary: #7445e0; --primary-hover: #5f33c4; --accent-2: #ff8fb8; }
:root[data-accent="rose"]    { --primary: #d6336c; --primary-hover: #b8245a; --accent-2: #ffa94d; }
:root[data-accent="amber"]   { --primary: #c98a00; --primary-hover: #a87300; --accent-2: #e4572e; }

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

/* Lenis smooth-scroll takes over scrolling when it is active */
html.lenis,
html.lenis body {
  height: auto;
  scroll-behavior: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

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

img {
  height: auto;
}

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

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

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

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--text);
  text-wrap: balance;
}

h3 {
  font-size: var(--fs-h3);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

p {
  text-wrap: pretty;
}

/* Serif italic accent words inside headlines: <em class="serif">love</em> */
.serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

::selection {
  background: var(--primary);
  color: #ffffff;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 400;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  transform: translateY(-150%);
  transition: transform var(--t-fast) ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

/* Paper grain over the whole page (very subtle) */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 500;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.09;
  mix-blend-mode: multiply;
}

:root[data-theme="dark"] .grain {
  mix-blend-mode: screen;
  opacity: 0.05;
}

@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;
  }
}
