/*
 * theme.css
 * Design tokens, typography, reset, and base element styling.
 * Refined-academic redesign of the Chatterjee faculty site.
 * UT burnt-orange theme with light + dark color schemes.
 */

/* Fonts -------------------------------------------------------------------- */
/* Source Serif 4 for headings (scholarly), Inter for body/UI. */
@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&display=swap");

/* Design tokens ------------------------------------------------------------ */
:root {
  /* Brand */
  --ut-orange: #bf5700;          /* official UT burnt orange */
  --ut-orange-strong: #a64a00;   /* hover / pressed */
  --ut-charcoal: #333f48;        /* UT secondary neutral */

  /* Light scheme (default) */
  --bg: #ffffff;
  --bg-subtle: #faf8f6;          /* warm off-white for rails & wells */
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e7e1db;
  --border-strong: #d8d0c8;

  --text: #20242a;
  --text-muted: #5c636b;
  --heading: #2b333a;

  --primary: var(--ut-orange);
  --primary-hover: var(--ut-orange-strong);
  --link: #a64a00;               /* AA-contrast orange for inline links */
  --link-hover: #bf5700;
  --on-primary: #ffffff;

  --accent-wash: #fbeede;        /* faint orange tint for highlights */
  --shadow-sm: 0 1px 2px rgba(40, 30, 20, 0.06), 0 1px 3px rgba(40, 30, 20, 0.08);
  --shadow-md: 0 4px 14px rgba(40, 30, 20, 0.10);

  /* Layout scale */
  --maxw: 1180px;
  --content-maxw: 760px;
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Source Serif 4", Georgia, "Times New Roman", serif;

  color-scheme: light;
}

/* Dark scheme — applied via [data-theme="dark"] (toggle) or OS preference. */
:root[data-theme="dark"] {
  --bg: #14171b;
  --bg-subtle: #1b1f24;
  --surface: #1b1f24;
  --surface-raised: #20252b;
  --border: #2b323a;
  --border-strong: #3a424c;

  --text: #e7e4e0;
  --text-muted: #a3acb5;
  --heading: #f1ede8;

  --primary: #d96a14;            /* slightly lifted orange for dark fills */
  --primary-hover: #ec7f2a;
  --link: #ff9248;               /* lightened for legibility on dark */
  --link-hover: #ffab70;
  --on-primary: #ffffff;

  --accent-wash: #2a2018;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);

  color-scheme: dark;
}

/* Follow OS preference when the user hasn't explicitly chosen a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b;
    --bg-subtle: #1b1f24;
    --surface: #1b1f24;
    --surface-raised: #20252b;
    --border: #2b323a;
    --border-strong: #3a424c;

    --text: #e7e4e0;
    --text-muted: #a3acb5;
    --heading: #f1ede8;

    --primary: #d96a14;
    --primary-hover: #ec7f2a;
    --link: #ff9248;
    --link-hover: #ffab70;
    --on-primary: #ffffff;

    --accent-wash: #2a2018;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);

    color-scheme: dark;
  }
}

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.58;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Base elements ------------------------------------------------------------ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  color: var(--heading);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1rem; }

a {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 0.15em;
  transition: color 0.12s ease;
}
a:hover { color: var(--link-hover); text-decoration: underline; }
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}

ul, ol { padding-left: 1.3em; }
li { margin: 0.3em 0; }

code, kbd, samp {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 0.9em;
  background: var(--accent-wash);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

em { color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

img { max-width: 100%; height: auto; }

::selection { background: var(--ut-orange); color: #fff; }
