/* ============================================================
   BASE.CSS — Reset + Design Tokens
   Ashwin Ramesh Personal Site
   Palette: Stone/Ink with Forest accent, Cartographic warmth
   ============================================================ */

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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: var(--space-16);
}

/* ── Custom Properties ──────────────────────────────────────── */
:root, [data-theme="light"] {
  /* Surfaces — warm parchment/stone */
  --color-bg:               #F5F3EE;
  --color-surface:          #F8F6F1;
  --color-surface-2:        #FAFAF7;
  --color-surface-offset:   #EDE9E2;
  --color-surface-dynamic:  #E5E0D7;
  --color-divider:          #D8D3C9;
  --color-border:           #CCC7BC;

  /* Text — deep ink */
  --color-text:             #1E1D1A;
  --color-text-muted:       #6E6B63;
  --color-text-faint:       #ABA89F;
  --color-text-inverse:     #F8F6F1;

  /* Primary — forest/moss green */
  --color-primary:          #2D5016;
  --color-primary-hover:    #1E3A0E;
  --color-primary-active:   #122508;
  --color-primary-highlight:#D4DEC9;
  --color-primary-subtle:   #EBF0E5;

  /* Accent — muted slate teal, used sparingly */
  --color-accent:           #3D6B6F;
  --color-accent-hover:     #2B4E51;

  /* Functional */
  --color-success:          #3A6B1E;
  --color-warning:          #8A5A1A;
  --color-error:            #8B2A2A;

  /* Shadows — warm-tinted */
  --shadow-sm:   0 1px 2px oklch(0.15 0.02 80 / 0.06);
  --shadow-md:   0 4px 16px oklch(0.15 0.02 80 / 0.09);
  --shadow-lg:   0 16px 48px oklch(0.15 0.02 80 / 0.13);
  --shadow-glow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.18);

  /* Typography */
  --font-display: 'Zodiak', 'Georgia', serif;
  --font-body:    'Satoshi', 'Helvetica Neue', sans-serif;
  --font-mono:    'JetBrains Mono', 'Menlo', monospace;

  /* Type scale — fluid */
  --text-xs:   clamp(0.75rem, 0.70rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.82rem + 0.28vw, 1rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.625vw, 1.5rem);
  --text-xl:   clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
  --text-2xl:  clamp(2rem, 1.2rem + 4vw, 4rem);
  --text-3xl:  clamp(2.5rem, 0.5rem + 7vw, 6rem);
  --text-hero: clamp(3.5rem, -0.5rem + 10vw, 8rem);

  /* Spacing */
  --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;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Layout */
  --content-narrow:  640px;
  --content-default: 1000px;
  --content-wide:    1280px;
  --gutter:          clamp(var(--space-6), 5vw, var(--space-16));

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast:   120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base:   200ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow:   400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mode */
[data-theme="dark"] {
  --color-bg:               #141311;
  --color-surface:          #1A1916;
  --color-surface-2:        #1F1D1A;
  --color-surface-offset:   #17160F;
  --color-surface-dynamic:  #252320;
  --color-divider:          #2A2825;
  --color-border:           #333029;

  --color-text:             #E8E5DF;
  --color-text-muted:       #8A8780;
  --color-text-faint:       #5A5750;
  --color-text-inverse:     #141311;

  --color-primary:          #7AB85A;
  --color-primary-hover:    #91CC6E;
  --color-primary-active:   #A8DE84;
  --color-primary-highlight:#2A3320;
  --color-primary-subtle:   #1E2619;

  --color-accent:           #6AABAD;
  --color-accent-hover:     #87C4C6;

  --shadow-sm:   0 1px 2px oklch(0 0 0 / 0.25);
  --shadow-md:   0 4px 16px oklch(0 0 0 / 0.40);
  --shadow-lg:   0 16px 48px oklch(0 0 0 / 0.55);
  --shadow-glow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:               #141311;
    --color-surface:          #1A1916;
    --color-surface-2:        #1F1D1A;
    --color-surface-offset:   #17160F;
    --color-surface-dynamic:  #252320;
    --color-divider:          #2A2825;
    --color-border:           #333029;
    --color-text:             #E8E5DF;
    --color-text-muted:       #8A8780;
    --color-text-faint:       #5A5750;
    --color-text-inverse:     #141311;
    --color-primary:          #7AB85A;
    --color-primary-hover:    #91CC6E;
    --color-primary-active:   #A8DE84;
    --color-primary-highlight:#2A3320;
    --color-primary-subtle:   #1E2619;
    --color-accent:           #6AABAD;
    --color-accent-hover:     #87C4C6;
    --shadow-sm:   0 1px 2px oklch(0 0 0 / 0.25);
    --shadow-md:   0 4px 16px oklch(0 0 0 / 0.40);
    --shadow-lg:   0 16px 48px oklch(0 0 0 / 0.55);
  }
}

/* ── Base Styles ─────────────────────────────────────────────── */
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

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

ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  text-wrap: balance;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

p, li, figcaption {
  text-wrap: pretty;
  max-width: 68ch;
}

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

a:hover { color: var(--color-primary); }

::selection {
  background: oklch(from var(--color-primary) l c h / 0.2);
  color: var(--color-text);
}

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

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a, button, [role="button"] {
  transition: color var(--transition-fast), background var(--transition-fast),
              border-color var(--transition-fast), opacity var(--transition-fast);
}

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

/* ── Utility Classes ─────────────────────────────────────────── */
.container {
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--wide {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: var(--content-narrow);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: clamp(var(--space-16), 8vw, var(--space-32));
}

.section--sm {
  padding-block: clamp(var(--space-10), 5vw, var(--space-20));
}

.label {
  font-size: var(--text-xs);
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }

/* Topo line texture overlay — subtle cartographic feel */
.topo-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cpath d='M0 80 Q50 70 100 80 Q150 90 200 80' stroke='%23000' stroke-width='0.4' fill='none' opacity='0.04'/%3E%3Cpath d='M0 120 Q60 108 120 120 Q160 130 200 120' stroke='%23000' stroke-width='0.4' fill='none' opacity='0.04'/%3E%3Cpath d='M0 40 Q80 30 140 40 Q170 48 200 40' stroke='%23000' stroke-width='0.4' fill='none' opacity='0.03'/%3E%3Cpath d='M0 160 Q40 150 100 160 Q155 170 200 160' stroke='%23000' stroke-width='0.4' fill='none' opacity='0.03'/%3E%3C/svg%3E");
  background-repeat: repeat;
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] .topo-bg::before {
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cpath d='M0 80 Q50 70 100 80 Q150 90 200 80' stroke='%23fff' stroke-width='0.4' fill='none' opacity='0.04'/%3E%3Cpath d='M0 120 Q60 108 120 120 Q160 130 200 120' stroke='%23fff' stroke-width='0.4' fill='none' opacity='0.04'/%3E%3Cpath d='M0 40 Q80 30 140 40 Q170 48 200 40' stroke='%23fff' stroke-width='0.4' fill='none' opacity='0.03'/%3E%3Cpath d='M0 160 Q40 150 100 160 Q155 170 200 160' stroke='%23fff' stroke-width='0.4' fill='none' opacity='0.03'/%3E%3C/svg%3E");
}

/* ── SVG Illustration Containers ───────────────────────────── */
.img-illustration {
  width: 100%;
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: block;
  line-height: 0;
}

.img-illustration--dark {
  background: #111410;
}

.img-illustration--portrait {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  height: 420px;
  overflow: hidden;
}

.img-illustration--portrait svg {
  width: 100%;
  height: 100%;
}

.img-illustration--hero-full {
  width: 100%;
  height: clamp(400px, 65vh, 700px);
  border-radius: 0;
}

.img-illustration--hero-full svg {
  width: 100%;
  height: 100%;
}

.img-illustration--card {
  width: 100%;
  aspect-ratio: 3/2;
}

.img-illustration--field {
  width: 100%;
  height: 340px;
  border-radius: var(--radius-md);
}

.img-illustration--field-sm {
  width: 180px;
  height: 150px;
  border-radius: var(--radius-md);
}

/* work-card images become illustration wrappers */
.work-card__image-wrap {
  width: 100%;
  overflow: hidden;
  line-height: 0;
}

.work-card--full .work-card__image-wrap {
  height: 100%;
}

.work-card--full .img-illustration {
  height: 100%;
  min-height: 260px;
  border-radius: 0;
}
