/* =====================================================
   TheTechBiscuit — base.css
   Light-default editorial design, dark mode via body.mode-dark
   ===================================================== */

/* ---- Self-hosted fonts (see /themes/techbiscuits/static/fonts/README.md) ---- */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: local('Fraunces'),
       url('/fonts/fraunces-variable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: local('Fraunces Italic'),
       url('/fonts/fraunces-italic-variable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: local('Newsreader'),
       url('/fonts/newsreader-variable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: local('Newsreader Italic'),
       url('/fonts/newsreader-italic-variable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Syne';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: local('Syne'),
       url('/fonts/syne-variable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: local('DM Mono Light'), local('DMMono-Light'),
       url('/fonts/dmmono-300.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('DM Mono'), local('DMMono-Regular'),
       url('/fonts/dmmono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: local('DM Mono Medium'), local('DMMono-Medium'),
       url('/fonts/dmmono-500.woff2') format('woff2');
}

/* ---- Design tokens: light (default) ---- */
:root {
  --paper:           #f7f3ec;
  --paper-raised:    #fbf8f2;
  --paper-deep:      #efe8dc;
  --ink:             #1a1410;
  --ink-soft:        #4a3f33;
  --ink-muted:       #8a7a66;
  --ink-faint:       #b8a890;
  --rule:            #e1d7c6;
  --rule-strong:     #c8bba4;

  --accent:          #c45a2c;
  --accent-hover:    #b04e22;
  --accent-wash:     #f3dccd;
  --secondary:       #3d7867;
  --secondary-wash:  #d9e6e1;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Newsreader', Georgia, serif;
  --font-mono:    'DM Mono', ui-monospace, monospace;
  --font-accent:  'Syne', sans-serif;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --container:        1240px;
  --container-narrow: 880px;

  --t-fast: 0.18s ease;
  --t-base: 0.25s ease;

  /* z-index scale */
  --z-sticky:  1000;
  --z-overlay: 9000;
  --z-system:  10000;
}

/* ---- Design tokens: dark override ---- */
body.mode-dark {
  --paper:          #17110d;
  --paper-raised:   #1e1812;
  --paper-deep:     #120d09;
  --ink:            #f0e6d6;
  --ink-soft:       #d4c7b2;
  --ink-muted:      #9a8672;
  --ink-faint:      #6d5e4c;
  --rule:           #2c231b;
  --rule-strong:    #3d3228;
  --accent-wash:    rgba(196, 90, 44, 0.12);
  --secondary:      #5a9b8a;
  --secondary-wash: rgba(90, 155, 138, 0.10);
}

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

/* ---- HTML base ---- */
html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

@media (max-width: 768px) { html { font-size: 15px; } }
@media (max-width: 480px) { html { font-size: 14px; } }

/* ---- Body ---- */
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.75;
  font-size: 1rem;
  font-weight: 400;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-base), color var(--t-base);
}

/* ---- Film grain overlay (opt-in via body.grain-on) ---- */
body.grain-on::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-system);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='.05'/%3E%3C/svg%3E");
  opacity: 0.4;
  mix-blend-mode: multiply;
}

body.mode-dark.grain-on::after {
  mix-blend-mode: overlay;
}

/* ---- Links ---- */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--accent); }

/* ---- Selection ---- */
::selection        { background: var(--accent); color: #fff; }
::-moz-selection   { background: var(--accent); color: #fff; }

/* ---- Focus ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---- Images ---- */
img { display: block; max-width: 100%; height: auto; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar             { width: 8px; }
::-webkit-scrollbar-track       { background: var(--paper-deep); }
::-webkit-scrollbar-thumb       { background: var(--rule-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  top: -48px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: var(--z-system);
  border-radius: 0 0 var(--r-md) 0;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }

/* ---- Screen-reader only ---- */
.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;
}

/* ---- Utility ---- */
.is-hidden { display: none !important; }
