/* Light palette is the base; dark redefines only the tokens. */
:root {
  --bg: #f4f4f1;
  --bg-tint-a: rgba(31, 94, 255, 0.09);
  --bg-tint-b: rgba(255, 122, 89, 0.08);
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #14161b;
  --muted: #545b6a;
  --faint: #8a92a1;
  --rule: #e6e7e3;
  --rule-soft: #eeefec;
  --accent: #2a5bd7;
  --accent-soft: rgba(42, 91, 215, 0.1);
  --shadow-sm: 0 1px 2px rgba(16, 18, 25, 0.05);
  --shadow-lg: 0 1px 2px rgba(16, 18, 25, 0.04), 0 24px 60px -20px rgba(16, 18, 25, 0.18);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d10;
    --bg-tint-a: rgba(96, 140, 255, 0.13);
    --bg-tint-b: rgba(255, 122, 89, 0.08);
    --surface: #14171c;
    --surface-2: #1b1f26;
    --text: #e9ebee;
    --muted: #a6adba;
    --faint: #767f8e;
    --rule: #262b33;
    --rule-soft: #1f242b;
    --accent: #7ea2ff;
    --accent-soft: rgba(126, 162, 255, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --bg-tint-a: rgba(96, 140, 255, 0.13);
  --bg-tint-b: rgba(255, 122, 89, 0.08);
  --surface: #14171c;
  --surface-2: #1b1f26;
  --text: #e9ebee;
  --muted: #a6adba;
  --faint: #767f8e;
  --rule: #262b33;
  --rule-soft: #1f242b;
  --accent: #7ea2ff;
  --accent-soft: rgba(126, 162, 255, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html[data-theme-preload] { visibility: hidden; }

body {
  margin: 0;
  padding: 3rem 1.25rem 5rem;
  background-color: var(--bg);
  /* Two soft washes behind the card so the page isn't a flat rectangle. */
  background-image:
    radial-gradient(60rem 32rem at 12% -8%, var(--bg-tint-a), transparent 60%),
    radial-gradient(48rem 28rem at 92% 4%, var(--bg-tint-b), transparent 62%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- toolbar ------------------------------------------------------------- */
.toolbar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
}
.btn:hover {
  color: var(--text);
  border-color: var(--faint);
  box-shadow: var(--shadow-sm), 0 6px 16px -8px rgba(16, 18, 25, 0.3);
  text-decoration: none;
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-icon { padding: 0.45rem 0.65rem; font-size: 0.9375rem; line-height: 1; }

/* --- page --------------------------------------------------------------- */
.page {
  position: relative;
  max-width: 47rem;
  margin: 0 auto;
  padding: clamp(1.75rem, 5vw, 3.5rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* --- masthead ----------------------------------------------------------- */
.masthead { position: relative; padding-bottom: 1.75rem; }
.masthead::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, var(--rule), transparent);
}

/* Monogram sits beside the name, not above it. */
.identity {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.identity-text { min-width: 0; }

.monogram {
  display: grid;
  place-items: center;
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 15px;
  background: var(--accent); /* fallback: color-mix() below is ignored by old browsers */
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8b5cf6));
  color: #fff;
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px -8px var(--accent);
}

.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 6.5vw, 2.875rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.headline {
  margin: 0.35rem 0 0;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}
.chip {
  display: inline-block;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8125rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
a.chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* --- sections ----------------------------------------------------------- */
.section { margin-top: 2.5rem; }
.section h2 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.15rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.section h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule-soft);
}
.section h2 span { flex: none; }

.summary { margin: 0; color: var(--muted); font-size: 1rem; }

/* A grid, not wrapped flex: the skill lines vary a lot in length and ragged
   pills read as clutter. Two even columns on desktop, one on a phone. */
.skills {
  display: grid;
  /* min() so the fixed 18rem track can never be wider than a narrow phone. */
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.skills li {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.875rem;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.skills li:hover { color: var(--text); border-color: var(--faint); transform: translateY(-1px); }

/* --- experience timeline ------------------------------------------------ */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 0.3125rem;
  top: 0.55rem;
  bottom: 0.6rem;
  width: 1px;
  background: linear-gradient(to bottom, var(--rule), var(--rule-soft));
}

.timeline .entry { position: relative; padding-bottom: 1.85rem; }
.timeline .entry:last-child { padding-bottom: 0; }
.timeline .entry::before {
  content: "";
  position: absolute;
  left: -1.5rem;
  top: 0.5rem;
  width: 11px;
  height: 11px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.timeline .entry:not(:first-child)::before {
  background: var(--faint);
  box-shadow: none;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.15rem 1rem;
}
.entry-head h3 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.dates {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.place {
  margin: 0.1rem 0 0.55rem;
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 500;
}
.body { margin: 0; color: var(--muted); font-size: 0.9375rem; }

/* --- education ---------------------------------------------------------- */
.education {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 0.75rem;
}
.edu-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface-2);
}
.edu-card h3 { margin: 0; font-size: 1rem; font-weight: 650; }
.edu-card .place { margin: 0.1rem 0 0.35rem; font-size: 0.875rem; }

/* --- empty state -------------------------------------------------------- */
.empty { max-width: 30rem; margin: 3rem auto; text-align: center; }
.empty h1 { font-family: var(--serif); font-weight: 600; }
.empty code {
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 0.875em;
}

@media (max-width: 34rem) {
  body { padding: 4.5rem 0.75rem 3rem; }
  .toolbar { top: 0.75rem; right: 0.75rem; }
  .page { border-radius: 14px; }
  .identity { gap: 0.85rem; }
  .monogram { width: 2.75rem; height: 2.75rem; border-radius: 13px; font-size: 1rem; }
  .entry-head { gap: 0; }
  .timeline { padding-left: 1.25rem; }
  .timeline .entry::before { left: -1.25rem; }
}

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