/* ==========================================================================
   Design Tokens, Zero-CLS Font Fallbacks, Dual Theme & Accessibility Base
   vibhavmithal.com — Understated Editorial Portfolio
   ========================================================================== */

/* Metric-adjusted local font fallbacks for CLS = 0.000 while Google Fonts load */
@font-face {
  font-family: 'Newsreader Fallback';
  src: local('Georgia'), local('Times New Roman');
  size-adjust: 97%;
  ascent-override: 93%;
  descent-override: 25%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Inter Fallback';
  src: local('Segoe UI'), local('Helvetica Neue'), local('Arial');
  size-adjust: 105%;
  ascent-override: 92%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Consolas'), local('SFMono-Regular'), local('Courier New');
  size-adjust: 100%;
  ascent-override: 95%;
  descent-override: 24%;
  line-gap-override: 0%;
}

:root,
html[data-theme='light'] {
  color-scheme: light;

  /* Alabaster Paper Palette */
  --bg: #FAF9F6;
  --surface: #F3F1EC;
  --card: #FFFFFF;
  --ink: #141413;
  --ink-2: #575653;
  --ink-3: #767570;
  --border: rgba(20, 20, 19, 0.09);
  --border-strong: rgba(20, 20, 19, 0.16);
  --accent: #1E3A5F;
  --accent-hover: #142843;
  --accent-soft: rgba(30, 58, 95, 0.08);
  --accent-ink: #FAF9F6;

  --header-bg: rgba(250, 249, 246, 0.86);
  --drawer-backdrop: rgba(20, 20, 19, 0.35);
  --shadow-sm: 0 1px 2px rgba(20, 20, 19, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 20, 19, 0.06);

  --logo-tile-bg: #FFFFFF;
  --logo-tile-border: rgba(20, 20, 19, 0.09);

  /* Typography */
  --font-serif: 'Newsreader', 'Newsreader Fallback', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', 'Inter Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type Scale */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.375rem;     /* 22px */
  --text-2xl: 1.75rem;     /* 28px */
  --text-hero: clamp(2.35rem, 5.2vw, 3.6rem);

  /* Spacing & Layout */
  --container-max: 980px;
  --header-height: 4rem;
  --touch-target: 2.75rem; /* 44px minimum hit area */

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Radii & Motion */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 220ms;

  /* Layering */
  --z-header: 40;
  --z-backdrop: 50;
  --z-drawer: 60;
}

html[data-theme='dark'] {
  color-scheme: dark;

  /* Obsidian Palette */
  --bg: #0C0D0F;
  --surface: #131518;
  --card: #181B1F;
  --ink: #EDEDEB;
  --ink-2: #A1A09A;
  --ink-3: #7A7973;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #7AA2F7;
  --accent-hover: #8DB4FF;
  --accent-soft: rgba(122, 162, 247, 0.12);
  --accent-ink: #0C0D0F;

  --header-bg: rgba(12, 13, 15, 0.86);
  --drawer-backdrop: rgba(0, 0, 0, 0.62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.36);

  --logo-tile-bg: #F8F7F4;
  --logo-tile-border: rgba(255, 255, 255, 0.14);
}

/* ==========================================================================
   Base Reset & Editorial Typography Defaults
   ========================================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color var(--duration-base) var(--ease),
              color var(--duration-base) var(--ease);
}

h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

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

a {
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Touch focus-ring hygiene: never leave sticky focus boxes after touch taps,
   while preserving high-contrast focus rings for keyboard navigation. */
:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

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

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

/* Screen-reader & keyboard skip helpers */
.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: -100%;
  left: var(--space-4);
  z-index: 100;
  padding: 0.65rem 1rem;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: top var(--duration-fast) var(--ease);
}

.skip-link:focus {
  top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
}

[hidden] {
  display: none !important;
}

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