:root {
  --bg: #fdf2f6;
  --surface: #ffffff;
  --ink: #2b1621;
  --muted: #7a5868;
  --line: #f3d6e2;
  --accent: #d23c7c;
  --accent-soft: #fbdcea;
  --max: 1040px;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 17px/1.65 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }

/* Nav */
nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
      backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
nav .wrap { display: flex; justify-content: space-between; align-items: center; height: 60px; }
.logo { font-family: Fraunces, serif; font-weight: 600; font-size: 20px; text-decoration: none; }
.logo { color: var(--accent); }
.logo { transition: opacity .25s, visibility .25s; }
.logo.is-hidden { opacity: 0; visibility: hidden; }
nav ul { list-style: none; display: flex; gap: 28px; font-size: 15px; }
nav ul a { text-decoration: none; color: var(--muted); }
nav ul a:hover { color: var(--ink); }

/* Hero */
.hero { padding: 96px 0 72px; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500;
         background: var(--accent-soft); color: var(--accent); padding: 6px 14px; border-radius: 999px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hero h1 { font-size: clamp(44px, 8vw, 84px); line-height: 1.02; margin: 24px 0 20px; }
.hero h1 em { font-style: italic; font-weight: 400; color: var(--accent); }
.lede { font-size: clamp(19px, 2.4vw, 23px); color: var(--muted); max-width: 640px; }
.meta { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px 24px; color: var(--muted); font-size: 15px; }
.cta { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-block; padding: 13px 24px; border-radius: 999px; font-weight: 500; font-size: 15px;
       text-decoration: none; border: 1px solid var(--ink); transition: transform .15s; }
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: var(--ink); color: var(--bg); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 32px 20px 32px 0; }
.stat + .stat { padding-left: 20px; border-left: 1px solid var(--line); }
.stat b { display: block; font-family: Fraunces, serif; font-size: 40px; font-weight: 600; line-height: 1.1; }
.stat span { font-size: 14px; color: var(--muted); }

section { padding: 88px 0 0; }
.label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); margin-bottom: 14px; }
section h2 { font-size: clamp(30px, 4.5vw, 42px); line-height: 1.15; margin-bottom: 28px; max-width: 720px; }

/* About */
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: 56px; align-items: start; }
.about p { font-size: 19px; }
.about p + p { margin-top: 16px; }
.skills { display: flex; flex-wrap: wrap; gap: 8px; }
.skills li { list-style: none; font-size: 14px; padding: 6px 14px; border: 1px solid var(--line);
             border-radius: 999px; background: var(--surface); }

/* Experience */
.org { display: grid; grid-template-columns: 220px 1fr; gap: 32px; padding: 36px 0; border-top: 1px solid var(--line); }
.org h3 { font-size: 24px; }
.org .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.role + .role { margin-top: 32px; }
.role h4 { font-size: 18px; font-weight: 600; }
.role .when { font-size: 14px; color: var(--muted); margin: 2px 0 10px; }
.role h4 + ul { margin-top: 10px; }
.role ul { padding-left: 18px; color: var(--muted); }
.role li { margin-bottom: 6px; }
.role li strong { color: var(--ink); font-weight: 600; }

/* Beyond */
.beyond { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.card .icon { font-size: 26px; margin-bottom: 10px; }
.card h3 { font-size: 21px; margin-bottom: 4px; }
.card .when { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.card p { color: var(--muted); }

/* Contact */
.contact h1 { font-size: clamp(34px, 6vw, 60px); line-height: 1.05; margin-bottom: 20px; max-width: 720px; }
.contact p:not(.label) { font-size: 19px; color: var(--muted); max-width: 560px; margin-bottom: 32px; }
footer { padding: 28px 0; font-size: 14px; color: var(--muted); }

@media (max-width: 760px) {
  nav ul { gap: 14px; font-size: 13px; }
  .logo { font-size: 17px; }
  .hero { padding: 64px 0 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat, .stat + .stat { padding: 24px 12px; border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stat b { font-size: 32px; }
  .about, .org, .beyond { grid-template-columns: 1fr; gap: 20px; }
  .wrap { padding: 0 16px; }
}

/* Multi-page additions */
nav ul a[aria-current="page"] { color: var(--accent); font-weight: 600; }
main { min-height: calc(100vh - 60px - 78px); }
main > section:first-child { padding-top: 72px; }

@media (max-width: 420px) {
  nav .wrap { gap: 12px; }
  nav ul { gap: 12px; }
}
@media (max-width: 360px) {
  nav ul { gap: 10px; font-size: 12px; }
  .logo { font-size: 16px; }
}

/* Portfolio */
.intro { font-size: 19px; color: var(--muted); max-width: 720px; }
.intro strong { color: var(--ink); font-weight: 600; }
.intro + .posts, .intro + .pieces { margin-top: 28px; }
.group { font-size: 26px; margin-bottom: 24px; }
.kicker { display: block; font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.more { display: inline-block; margin-top: 14px; font-size: 14px; font-weight: 600; }
.posts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.post, .piece { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; text-decoration: none;
                transition: transform .15s, border-color .15s; }
.post { padding: 26px; display: flex; flex-direction: column; }
.post h4, .piece h4 { font-family: Fraunces, Georgia, serif; font-size: 20px; line-height: 1.3; margin-bottom: 8px; }
.post p, .piece p { color: var(--muted); font-size: 15px; }
.post .more { margin-top: auto; padding-top: 14px; align-self: center; }
a.post:hover, a.piece:hover { transform: translateY(-3px); border-color: var(--accent); }
.pieces { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.piece { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: 1fr auto; gap: 18px 22px; padding: 20px; align-items: start; }
.piece > .more, .piece > .links { grid-column: 1 / -1; margin-top: 0; }
.piece > .more { justify-self: center; }
.piece .links { display: flex; flex-wrap: wrap; justify-content: space-evenly; gap: 6px 18px; font-size: 14px; font-weight: 600; }
.piece .links a { color: var(--ink); text-decoration: none; }
.piece .links a:hover { color: var(--accent); }
.piece > a { display: block; }
.piece > a:hover img { border-color: var(--accent); }
.piece img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: top; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 900px) {
  .pieces { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .piece { grid-template-columns: 1fr; }
  .piece img { max-height: 340px; }
}
main > section.wrap + section.wrap { padding-top: 72px; }
section[id] { scroll-margin-top: 60px; }
.about p.label { font-size: 13px; }
.hero.wrap { padding-left: 24px; padding-right: 24px; }
@media (max-width: 760px) { .hero.wrap { padding-left: 16px; padding-right: 16px; } }

/* Resume page */
.resume { padding-top: 72px; }
.r-head { padding-bottom: 28px; }
.r-head h1 { font-size: clamp(40px, 7vw, 64px); line-height: 1.05; }
.r-title { font-size: 20px; color: var(--muted); margin-top: 8px; }
.r-contact { margin-top: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 15px; color: var(--muted); }
.r-contact a { color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--line); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.r-contact a:hover { color: var(--accent); text-decoration-color: currentColor; }
.r-sec { border-top: 2px solid var(--line); padding: 26px 0 36px; }
.r-sec h2 { font-family: Inter, system-ui, sans-serif; font-size: 13px; font-weight: 600; text-transform: uppercase;
            letter-spacing: .12em; color: var(--accent); margin: 0 0 18px; max-width: none; }
.r-body { max-width: 760px; }
.r-body p + p { margin-top: 14px; }
.r-sec .org:first-of-type { border-top: 0; padding-top: 6px; }
.r-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.r-edu span { color: var(--muted); }
@media (max-width: 760px) {
  .resume { padding-top: 48px; }
  .r-grid { grid-template-columns: 1fr; gap: 28px; }
}
@media print {
  nav, footer { display: none; }
  body { background: #fff; color: #000; font-size: 12px; }
  .resume { padding-top: 0; }
}
.resume .org h3 { font-size: 20px; line-height: 1.3; }

/* Footer spacing */
footer.wrap { padding-top: 32px; padding-bottom: 40px; border-top: 1px solid var(--line); }
main { padding-bottom: 72px; min-height: calc(100vh - 60px - 94px); }
footer.wrap { max-width: none; padding-left: max(24px, calc((100% - var(--max)) / 2 + 24px)); padding-right: max(24px, calc((100% - var(--max)) / 2 + 24px)); }
@media (max-width: 760px) { main { padding-bottom: 48px; } footer.wrap { padding-left: 16px; padding-right: 16px; } }
.hero.wrap { padding-top: 96px; padding-bottom: 72px; }
@media (max-width: 760px) { .hero.wrap { padding-top: 56px; padding-bottom: 48px; } }
.hero .stats { margin: 40px 0 36px; }
.ext { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ext:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Promotion tree (mobile only): links each role back to the org heading */
@media (max-width: 760px) {
  .roles { --tree: color-mix(in srgb, var(--muted) 40%, var(--bg)); padding-left: 22px; margin-left: 4px; }
  .roles .role { position: relative; }
  .roles .role::before { content: ""; position: absolute; left: -20px; top: -32px; bottom: 0; border-left: 1px solid var(--tree); }
  .roles .role:first-child::before { top: -14px; }
  .roles .role:last-child::before { bottom: auto; height: calc(32px + 14px); }
  .roles .role::after { content: ""; position: absolute; left: -20px; top: 13px; width: 14px; border-top: 1px solid var(--tree); }
}

/* Home hero: staggered fade-up on load */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.hero h1, .hero .lede, .hero .stat, .hero .cta { animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.hero .lede { animation-delay: .12s; }
.hero .stat:nth-child(1) { animation-delay: .26s; }
.hero .stat:nth-child(2) { animation-delay: .34s; }
.hero .stat:nth-child(3) { animation-delay: .42s; }
.hero .stat:nth-child(4) { animation-delay: .5s; }
.hero .cta { animation-delay: .62s; }
@media (prefers-reduced-motion: reduce) {
  .hero h1, .hero .lede, .hero .stat, .hero .cta { animation: none; }
}

/* Home and Contact fit the viewport; only Resume and Portfolio scroll */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; min-height: 0; }
footer.wrap { width: 100%; }
.fit main { padding-bottom: 0; display: flex; flex-direction: column; justify-content: center; }
.fit main > section:first-child { padding-top: 0; }
.fit .hero.wrap { width: 100%; padding-top: clamp(24px, 6vh, 96px); padding-bottom: clamp(24px, 6vh, 72px); }
.fit .hero .stats { margin: clamp(20px, 4.5vh, 40px) 0 clamp(20px, 4vh, 36px); }
.fit .hero .stat { padding-top: clamp(16px, 3.5vh, 32px); padding-bottom: clamp(16px, 3.5vh, 32px); }
.fit .contact { padding: clamp(24px, 6vh, 72px) 0; }
.fit .hero h1 { font-size: clamp(40px, min(8vw, 10vh), 84px); margin-bottom: clamp(10px, 2.2vh, 20px); }
.fit .hero .lede { font-size: clamp(17px, min(2.4vw, 2.8vh), 23px); }
.fit .hero .cta { margin-top: 0; }
@media (max-height: 760px) { .fit .hero .stat b { font-size: 32px; } }

/* Home lede: cycle through formats */
.rotator { display: inline-grid; vertical-align: top; overflow: hidden; color: var(--accent); }
.rotator > a { grid-area: 1 / 1; white-space: nowrap; color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-decoration-thickness: 2px; text-underline-offset: 3px; animation: cycle 7.5s ease-in-out infinite both; }
.rotator > a:hover { text-decoration-color: currentColor; }
.rotator > a:nth-child(2) { animation-delay: 2.5s; }
.rotator > a:nth-child(3) { animation-delay: 5s; }
.rotator:hover > a { animation-play-state: paused; }
@keyframes cycle {
  0% { opacity: 0; transform: translateY(.6em); visibility: hidden; }
  5%, 30% { opacity: 1; transform: none; visibility: visible; }
  35%, 100% { opacity: 0; transform: translateY(-.6em); visibility: hidden; }
}
.rotator-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.rotator-text a { color: var(--accent); }
/* Keyboard users tab into the static links, which then show in place of the animation */
.lede:has(.rotator-text :focus-visible) .rotator { display: none; }
.rotator-text:has(:focus-visible) { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; }
@media (prefers-reduced-motion: reduce) {
  .rotator { display: none; }
  .rotator-text { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; }
}

/* Social logos next to LinkedIn and Instagram links */
.ico { display: inline-block; width: 1em; height: 1em; vertical-align: -0.14em; margin-right: .4em; }

/* Home and Contact: WebGL background behind the page */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
/* Let the gradient run up behind the nav (Home doesn't scroll, so nothing passes underneath) */
body:has(#bg) nav { background: transparent; backdrop-filter: none; }
/* Pink stat grid on Home, strong enough to read over the gradient */
.hero .stats, .hero .stat { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.hero .stat b { color: var(--accent); }
/* Home and Contact in pink: accent headings and buttons, deeper rose for body text so it stays readable */
.hero h1, .contact h1 { color: var(--accent); }
.hero .lede, .hero .stat span, .contact p:not(.label) { color: color-mix(in srgb, var(--accent) 70%, var(--ink)); }
.hero .btn, .contact .btn { border-color: var(--accent); color: var(--accent); }
.hero .btn.primary, .contact .btn.primary { background: var(--accent); color: #fff; }
/* The envelope emoji is wider than tall, so scale it up to sit level with the 1em SVG icons */
.emoji { display: inline-block; font-size: 1.3em; line-height: 1; vertical-align: -0.1em; margin-right: .25em; }

/* Home stats as a looping strip (set up by script; without it they stay a grid) */
.hero .stats.marquee { display: block; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.stats-track { display: flex; width: max-content; animation: marquee 28s linear infinite; }
.stats.marquee:hover .stats-track { animation-play-state: paused; }
.stats.marquee .stat, .stats.marquee .stat + .stat { flex: none; width: 270px; padding-left: 24px; padding-right: 24px;
  border-left: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-bottom: 0; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (max-width: 760px) { .stats.marquee .stat, .stats.marquee .stat + .stat { width: 200px; padding-left: 16px; padding-right: 16px; } }

/* Pin the Home name to the same spot and size as the Resume heading, so switching tabs doesn't move it */
.fit main:has(> .hero) { justify-content: flex-start; }
.fit .hero.wrap { padding-top: 72px; }
.fit .hero h1 { font-size: clamp(40px, 7vw, 64px); line-height: 1.05; margin-top: 0; animation: none; }
@media (max-width: 760px) { .fit .hero.wrap { padding-top: 48px; } }
/* With the name pinned to the top, tighten the space below it so Home still fits short screens */
.fit .hero.wrap { padding-bottom: clamp(16px, 4vh, 72px); }
.fit .hero .stats { margin: clamp(16px, 3.6vh, 40px) 0 clamp(16px, 3.2vh, 36px); }
@media (max-height: 700px) {
  .fit .hero h1 { margin-bottom: 10px; }
  .fit .hero .stat { padding-top: 14px; padding-bottom: 14px; }
  .fit .hero .lede { font-size: 17px; line-height: 1.5; }
}
/* Resume header: LinkedIn logo in LinkedIn's brand blue */
.r-contact .ico { color: #0a66c2; }
/* 📍 is tall and narrow with blank sides: match the 1em icons' height and trim the side space */
.emoji.emoji-pin { font-size: 1.09em; vertical-align: -0.07em; margin-left: -0.25em; margin-right: .12em; }
/* Resume contact list: every icon gets the same 20px slot so the three lines' text starts at one edge */
.r-contact .ico, .r-contact .emoji, .r-contact .emoji.emoji-pin { width: 20px; margin: 0 6px 0 0; text-align: center; }
.r-contact .ico { box-sizing: border-box; padding: 0 2.5px; height: 15px; }

/* Nav logo: full name when it fits beside the links; otherwise "Kavoosi" wraps to a hidden second line */
nav .wrap { gap: 24px; }
nav ul { flex-shrink: 0; }
.logo { display: flex; flex-wrap: wrap; column-gap: .28em; flex: 0 1 auto; min-width: min-content; height: 1.3em; line-height: 1.3; overflow: hidden; }

/* Visible to search engines and screen readers only */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
