/* ===== Global layout ===== */
:root {
  --bg: #0f172a;         /* deep navy / slate */
  --text-main: #f8fafc;  /* near-white */
  --text-dim: #94a3b8;   /* gray-blue */
  --accent: #38bdf8;     /* cyan-ish */
  --card-bg: #131a2b;    /* darker panel for contrast */
  --card-bg-elev: #1a2236; /* elevated surface */
  --border-color: #2b3a54;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --max-width: 1024px;
  --line-height: 1.6;
  --font-stack: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Inter", "SF Pro Text", "Apple Color Emoji", "Segoe UI Emoji";
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.2);
  /* Extra width for the header only (keeps main content width unchanged) */
  --header-extra-width: 0px;
}

/* Light theme variables */
[data-theme='light'] {
  --bg: #f8fafc;
  --text-main: #0f172a;
  --text-dim: #334155;
  --accent: #0ea5e9;
  --card-bg: #ffffff;
  --card-bg-elev: #ffffff;
  --border-color: #e2e8f0;
  --shadow-lg: 0 18px 50px rgba(2,6,23,0.12), 0 1px 6px rgba(2,6,23,0.06);
  --shadow-md: 0 10px 26px rgba(2,6,23,0.10), 0 1px 4px rgba(2,6,23,0.05);
}

/* Light theme surfaces */
[data-theme='light'] body {
  background: radial-gradient(1200px 600px at 10% -10%, rgba(14,165,233,0.12), transparent 60%),
              radial-gradient(1200px 600px at 90% -20%, rgba(2,6,23,0.06), transparent 60%),
              var(--bg);
}

[data-theme='light'] .site-header {
  background: rgba(255,255,255,0.7);
  border-bottom-color: var(--border-color);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-stack);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(56,189,248,0.08), transparent 60%),
              radial-gradient(1200px 600px at 90% -20%, rgba(100,116,139,0.12), transparent 60%),
              var(--bg);
  color: var(--text-main);
  line-height: var(--line-height);
  font-size: 16px;
}

/* container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

/* ===== Header / nav ===== */
.site-header {
  border-bottom: 1px solid var(--border-color);
  background: rgba(10,15,28,0.6);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  position: sticky;
  top: 0;
  z-index: 999;
}

/* Smooth transitions for shrink behavior */
.site-header, .site-header .container, .avatar, .name, .tagline, .nav a, .theme-toggle {
  transition: padding 180ms ease, margin 180ms ease, font-size 180ms ease, height 180ms ease, opacity 180ms ease, width 180ms ease, gap 180ms ease;
}

/* Give header its own vertical rhythm so we can shrink it without affecting other .container sections */
.site-header .container {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
  /* Make header a bit wider so nav fits on one line when shrunk */
  max-width: calc(var(--max-width) + var(--header-extra-width));
}

/* Shrink state applied when scrolling */
.site-header.shrink .container {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.header-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Reduce gaps slightly when shrunk */
.site-header.shrink .header-content { gap: 0.3rem; }
/* Tighten tool spacing when shrunk to save width */
.site-header.shrink .tools { gap: 0.5rem 0.6rem; }

.name {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

/* Tighter name size when shrunk */
.site-header.shrink .name { font-size: 1.1rem; }

.tagline {
  color: var(--text-dim);
  font-size: 0.96rem;
  margin: 0.35rem 0 0 0;
  max-width: 62ch;
}

/* Make tagline disappear when shrunk for maximum compactness */
.site-header.shrink .tagline { display: none; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.nav a {
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  position: relative;
}

/* Compact link padding and size when shrunk */
.site-header.shrink .nav { gap: 0.35rem 0.6rem; }
.site-header.shrink .nav a { padding: 0.28rem 0.5rem; font-size: 0.86rem; }

/* Header intro with avatar */
.intro {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 9999px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  background: #cbd5e1;
}

/* Smaller avatar when shrunk */
.site-header.shrink .avatar { width: 40px; height: 40px; border-width: 1px; }

/* Right-side tools (nav + toggle) */
.tools {
  display: flex;
  align-items: center;
  gap: 0.6rem 0.8rem;
}

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
/* Compact toggle when shrunk */
.site-header.shrink .theme-toggle { width: 32px; height: 32px; }
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background-color: rgba(56,189,248,0.08);
}
.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(56,189,248,0.25);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  font-size: 1rem;
  line-height: 1;
}

/* Show icon based on current theme (show what you are switching to) */
[data-theme='dark'] .theme-toggle .icon-sun { display: inline; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }
[data-theme='light'] .theme-toggle .icon-sun { display: none; }
[data-theme='light'] .theme-toggle .icon-moon { display: inline; }

/* wider screens: align header */
@media (min-width: 700px) {
  .header-content {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
  .tools { gap: 0.8rem 1rem; }
  .avatar { width: 76px; height: 76px; }
  /* Keep shrunk avatar small even on wide screens */
  .site-header.shrink .avatar { width: 44px; height: 44px; }
  /* On wide screens, force nav to stay in one row when shrunk */
  .site-header.shrink .nav { flex-wrap: wrap; }
}

/* Mobile: hide intro (avatar + name) and theme toggle when shrunk so only nav remains */
@media (max-width: 699px) {
  .site-header.shrink .intro { display: none; }
  .site-header.shrink .theme-toggle { display: none; }
}

/* ===== Main sections ===== */
.main-content {
  padding-top: 1.5rem;
  padding-bottom: 4rem;
}

.section-block {
  margin: 1.25rem 0 1.5rem;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.2rem 0.9rem;
  box-shadow: var(--shadow-md);
}

.section-block:hover {
  transform: translateY(-1px);
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: var(--shadow-lg);
  background: linear-gradient(0deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02)) var(--card-bg);
}

.section-block h2 {
  margin: 0 0 0.9rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* text */
p {
  margin: 0.4rem 0 0.75rem;
  color: var(--text-main);
  font-size: 0.97rem;
}

strong {
  color: var(--text-main);
  font-weight: 600;
}

/* ===== Items (experience, projects) ===== */
.item + .item {
  margin-top: 1.1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.1rem;
}

.item-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}

.item-title {
  font-size: 0.98rem;
  font-weight: 650;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.item-date {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.item-desc {
  font-size: 0.94rem;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 70ch;
  white-space: pre-line; /* keep intended line breaks from HTML */
}

.item-links {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.75rem;
}

.item-links a {
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
}

.item-links a:hover {
  background-color: rgba(56,189,248,0.07);
  box-shadow: 0 8px 24px rgba(56,189,248,0.35);
  transition: all 150ms;
}

/* make head row horizontal on larger screens */
@media (min-width: 560px) {
  .item-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}

/* ===== Contact section ===== */
#contact p {
  margin-bottom: 0.5rem;
  font-size: 0.96rem;
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.contact-list a {
  color: var(--accent);
  text-decoration: none;
}

.contact-list a:hover,
.contact-list a:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  margin-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.footer p {
  color: var(--text-dim);
  margin-bottom: 0;
}

/* ===== Utilities ===== */
/* Prevent header from covering anchor targets */
:target {
  scroll-margin-top: 84px;
}

/* Ensure section anchors account for header height on small screens too */
:target { scroll-margin-top: 92px; }

/* ===== Content links ===== */
.main-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent);
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
  transition: color 150ms, text-decoration-color 150ms, text-decoration-thickness 150ms;
}
.main-content a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}
.main-content a:visited {
  color: var(--accent); /* avoid default purple */
}
.main-content a:focus-visible {
  outline: none;
  text-decoration-thickness: 3px;
  text-decoration-color: currentColor;
}