/* ==========================================================================
   Minimal Academic + Modern Computational Scientist Theme
   - Mobile-first
   - Accessible focus states
   - Relative paths everywhere
   - One muted accent color via CSS variables
   Fonts loaded in HTML:
   - Headings: Crimson Pro (serif)
   - Body: Inter (sans)
   ========================================================================== */

/* ------------------------------
   CSS Variables (Palette & Type)
   ------------------------------ */
:root {
  /* Palette */
  --bg: #fbfaf7; /* off-white */
  --surface: #ffffff; /* cards */
  --text: #1f2328; /* near-black */
  --muted: #5b6470; /* neutral gray */
  --muted-2: #7a8593; /* lighter gray */
  --border: #e6e3dd; /* warm gray border */
  --shadow: rgba(17, 24, 39, 0.06);

  /* Accent (choose one; currently deep muted navy) */
  --accent: #1f3a5f;
  --accent-2: #2b547e; /* hover */
  --accent-soft: rgba(31, 58, 95, 0.1);

  /* Typography */
  --font-body:
    "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-heading:
    "Crimson Pro", ui-serif, Georgia, "Times New Roman", Times, serif;

  /* Layout */
  --container: 1100px;
  --radius: 14px;
  --radius-sm: 10px;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* Focus ring */
  --focus: 0 0 0 3px rgba(31, 58, 95, 0.28);
}

/* Optional dark mode (enabled by JS adding data-theme="dark" to <html>)
   Keep it subtle and readable. */
html[data-theme="dark"] {
  --bg: #0f141a;
  --surface: #141b23;
  --text: #f1f4f8;
  --muted: #b7c0cc;
  --muted-2: #94a2b3;
  --border: #243244;
  --shadow: rgba(0, 0, 0, 0.35);

  --accent: #7fb1d6; /* soft sky */
  --accent-2: #9ac6e6;
  --accent-soft: rgba(127, 177, 214, 0.14);

  --focus: 0 0 0 3px rgba(127, 177, 214, 0.25);
}

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

html,
body {
  height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.14em;
}
a:hover {
  color: var(--accent-2);
}
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* ------------------------------
   Layout Helpers
   ------------------------------ */
.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

.narrow {
  width: min(100% - 2rem, 760px);
  margin-inline: auto;
}

.section {
  padding: var(--space-7) 0;
}

.section.alt {
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0) 30%,
    rgba(31, 58, 95, 0.03) 100%
  );
}

/* ------------------------------
   Typography
   ------------------------------ */
h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3) 0;
}

h1 {
  font-size: clamp(2rem, 3.4vw, 3.1rem);
}
h2 {
  font-size: clamp(1.6rem, 2.2vw, 2.1rem);
}
h3 {
  font-size: clamp(1.25rem, 1.6vw, 1.55rem);
}

p {
  margin: 0 0 var(--space-4) 0;
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 70ch;
  text-align: justify;
}

.small {
  font-size: 0.95rem;
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

/* ------------------------------
   Collapsible section headings
   ------------------------------ */

.is-collapsible > h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, var(--accent-soft) 12%);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.collapse-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border) 80%);
  background: color-mix(in srgb, var(--surface) 82%, var(--accent-soft) 18%);
}

.collapse-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.collapse-toggle:active {
  transform: translateY(1px);
}

.collapse-toggle .chev {
  display: block;
  line-height: 1;
  font-size: 1rem;
  transform: rotate(0deg);
  transition: transform 140ms ease;
}

/* Collapsed state: rotate chevron to point sideways */
.collapse-toggle[aria-expanded="false"] .chev {
  transform: rotate(-90deg);
}

/* Optional: a little breathing room when collapsed/expanded */
.collapsible-content {
  margin-top: var(--space-3);
}

.is-collapsible > h2 {
  cursor: pointer;
  user-select: none;
}

.is-collapsible > h2:hover {
  color: var(--accent);
}

/* ------------------------------
   Skip Link
   ------------------------------ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
  width: auto;
  height: auto;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px var(--shadow);
  z-index: 1000;
}

/* ------------------------------
   Header / Navigation
   ------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, var(--surface) 8%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) 0;
}

.site-branding {
  min-width: 190px;
}

.site-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  text-decoration: none;
}
.site-title:hover {
  color: var(--accent);
}

.site-tagline {
  margin: var(--space-1) 0 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.site-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.site-nav a {
  display: inline-block;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
}
.site-nav a:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}
.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border) 75%);
}

/* ------------------------------
   Hero
   ------------------------------ */
.hero {
  padding-top: var(--space-6);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: center;
}

.hero-text h1 {
  margin-bottom: var(--space-4);
}

.hero-image img {
  border-radius: calc(var(--radius) + 6px);
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px var(--shadow);
  background: var(--surface);
}

@media (min-width: 860px) {
  .hero-inner {
    grid-template-columns: 1.35fr 0.65fr;
  }
  .hero-image {
    justify-self: end;
    width: min(340px, 100%);
  }
}

/* ------------------------------
   Buttons
   ------------------------------ */
.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.78rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 600;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  color: var(--surface);
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border) 45%);
}
.button.primary:hover {
  background: var(--accent-2);
}

.button.secondary {
  color: var(--text);
  background: var(--surface);
}
.button.secondary:hover {
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border) 80%);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%);
}

/* ------------------------------
   Cards / Grids
   ------------------------------ */
.card-grid {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.card-grid.three {
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .card-grid.three {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: 0 10px 28px var(--shadow);
  text-align: justify;
}

.card h3 {
  margin-top: 0;
}
.card p {
  color: var(--muted);
  margin-bottom: 0;
}

/* Optional "card link" style if used later */
.card a {
  font-weight: 600;
}

/* ------------------------------
   Timeline / Lists
   ------------------------------ */
.subsection {
  margin-top: var(--space-6);
}

.timeline {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0 0;
  display: grid;
  gap: var(--space-3);
  line-height: 1.5;
}

.timeline li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: 0 8px 20px var(--shadow);
}

.timeline strong {
  font-weight: 700;
  color: var(--text);
}

/* ------------------------------
   Footer
   ------------------------------ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-6) 0;
  margin-top: var(--space-7);
  background: color-mix(in srgb, var(--bg) 92%, var(--surface) 8%);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: flex-start;
  justify-content: space-between;
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    align-items: center;
  }
}

.social-icons {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.social-icons a {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.social-icons a:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border) 80%);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%);
}

.social-icons svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

/* Some inline SVGs may use fill instead of stroke (e.g., GitHub path) */
.social-icons svg path {
  fill: currentColor;
  stroke: none;
}

/* ------------------------------
   Visit Counter
   ------------------------------ */
.visit-counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent-soft) 8%);
  box-shadow: 0 8px 18px var(--shadow);
}

.visit-counter__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.visit-counter__value {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-weight: 700;
  color: var(--text);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border) 82%);
}

html[data-theme="dark"] .visit-counter__value {
  background: color-mix(in srgb, var(--surface) 80%, black 20%);
}

/* ------------------------------
   Content Blocks (for inner pages)
   ------------------------------ */
.page-header {
  padding: var(--space-6) 0 var(--space-4) 0;
}

.page-header p {
  color: var(--muted);
  max-width: 75ch;
}

.content {
  padding: var(--space-3) 0 var(--space-7) 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, var(--accent-soft) 10%);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Simple table style if needed later */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th,
td {
  text-align: left;
  padding: 0.85rem;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 90%, var(--accent-soft) 10%);
}
tr:last-child td {
  border-bottom: 0;
}

/* ------------------------------
   Forms (contact page future-proofing)
   ------------------------------ */
input,
textarea {
  font: inherit;
}

.site-quote {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.4rem;
}
