/* Palette — cream, moss green, burgundy, plum, dusty rose, antique gold */
:root {
  --bg: #f6efe6;
  --bg-2: #fdf9f3;
  --fg: #2e1a1e;          /* deep wine-brown */
  --muted: #7d6660;
  --line: rgba(46,26,30,.12);
  --tile: #fbf6ee;
  --tile-hover: #f1e6dc;
  --accent: #7a2238;      /* burgundy */
  --sage: #5f7a45;        /* moss green */
  --clay: #b8893a;        /* antique gold */
  --olive: #3f5a34;       /* bottle green */
  --rose: #d9a5a8;        /* dusty rose */
  --plum: #6e2a4f;
  --sand: #efdcd6;        /* blush */
  --spot: rgba(122,34,56,.07);
  --radius: 20px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
:root[data-theme="dark"] {
  --bg: #2a1519;          /* wine */
  --bg-2: #341b20;
  --fg: #f3e8dc;
  --muted: #c2a9a2;
  --line: rgba(243,232,220,.12);
  --tile: #331a1f;
  --tile-hover: #3e2127;
  --accent: #e0a3a6;      /* rose on dark */
  --sage: #8fa874;
  --clay: #d4a64e;
  --olive: #6f8d57;
  --rose: #d9a5a8;
  --plum: #9b4a74;
  --sand: #4a252c;
  --spot: rgba(224,163,166,.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.65 var(--sans); -webkit-font-smoothing: antialiased;
  overflow-x: hidden; transition: background .4s, color .4s;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
em { font-style: italic; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); font-size: .82em; }
.muted { color: var(--muted); }
.tiny { font-size: .75rem; }
kbd {
  font-family: var(--mono); font-size: .7rem; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--tile); margin: 0 2px;
}
::selection { background: var(--accent); color: #fff; }

/* subtle paper grain */
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .3  0 0 0 .18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
:root[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .12; }

.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 100;
  background: linear-gradient(90deg, var(--sage), var(--accent), var(--clay)); transform-origin: 0 50%; transform: scaleX(0);
}

/* ---------- nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px max(20px, calc((100% - 1100px) / 2));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.brand-mark {
  font-family: var(--serif); font-size: 1.35rem; font-style: italic; letter-spacing: -.02em; color: var(--fg);
}
.brand-mark::after { content: "✦"; color: var(--clay); font-size: .7em; margin-left: 2px; vertical-align: super; font-style: normal; }
.nav-links { display: flex; gap: 28px; }
.nav-links a { font-size: .9rem; color: var(--muted); position: relative; transition: color .2s; }
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .3s ease;
}
.nav-links a:hover, .nav-links a.active { color: var(--fg); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.nav-actions { display: flex; gap: 8px; }
.icon-btn, .kbd-btn {
  height: 34px; min-width: 34px; display: grid; place-items: center; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); transition: color .2s, background .2s;
}
.kbd-btn { padding: 0 12px; font-family: var(--mono); font-size: .72rem; display: flex; gap: 2px; align-items: center; }
.icon-btn:hover, .kbd-btn:hover { color: var(--fg); background: var(--tile-hover); }
.i-moon { display: block; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: 100svh; display: flex; align-items: center;
  width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding: 120px 0 80px;
}
.hero-inner { position: relative; z-index: 1; max-width: 680px; }
.hero-shape {
  position: absolute; right: 0; top: 50%; transform: translateY(-46%);
  width: min(42vw, 440px); height: auto; z-index: 0;
}
.hero-shape .a1 { fill: var(--sage); opacity: .9; }
.hero-shape .a2 { fill: #7a2238; }
.hero-shape .a3 { fill: var(--rose); opacity: .9; }
.hero-shape .star { fill: var(--clay); transform-box: fill-box; transform-origin: center; animation: twinkle 6s ease-in-out infinite; }
.hero-shape .star.s2 { animation-delay: -3s; }
@keyframes twinkle { 50% { transform: rotate(20deg) scale(.88); } }
.status-pill {
  display: inline-flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted);
}
.status-pill:hover { color: var(--fg); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); position: relative; }
.pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--sage);
  animation: ping 2.4s cubic-bezier(0,0,.2,1) infinite;
}
@keyframes ping { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }
.hero-title {
  font-family: var(--serif); font-weight: 300; margin: 26px 0 18px; line-height: .98; letter-spacing: -.035em;
  font-size: clamp(3.2rem, 9.5vw, 7.5rem); font-variation-settings: "opsz" 144;
}
.hero-title .line { display: block; }
.hero-title em { color: var(--accent); font-weight: 300; }
.hero-sub { font-size: clamp(1.05rem, 2vw, 1.3rem); color: var(--muted); margin: 0 0 40px; min-height: 1.6em; }
.typed { color: var(--fg); }
.caret { color: var(--accent); animation: blink 1s steps(1) infinite; margin-left: 2px; font-weight: 300; }
@keyframes blink { 50% { opacity: 0; } }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: 999px;
  font-weight: 500; font-size: .92rem; border: 1px solid transparent;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), background .25s, color .25s, border-color .25s;
}
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-ghost { border-color: var(--line); background: transparent; }
.btn-ghost:hover { border-color: var(--fg); }
.btn-light { background: #fdf9f3; color: #2e1a1e; }
.btn-light:hover { background: #fff; }
.scroll-hint {
  position: absolute; bottom: 32px; left: 0; width: 1px; height: 48px; background: var(--line); overflow: hidden;
}
.scroll-hint span {
  position: absolute; left: 0; top: -50%; width: 1px; height: 50%; background: var(--accent);
  animation: line 2.2s ease-in-out infinite;
}
@keyframes line { to { top: 100%; } }

/* ---------- sections ---------- */
.section { width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding: 110px 0 30px; }
.section-head {
  display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: baseline;
  margin-bottom: 44px; padding-top: 22px; border-top: 1px solid var(--line);
}
.eyebrow { font-family: var(--mono); font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.section-head h2, .contact-title {
  font-family: var(--serif); font-weight: 300; letter-spacing: -.03em; line-height: 1.05; margin: 0;
  font-size: clamp(2.2rem, 5vw, 3.6rem); font-variation-settings: "opsz" 144;
}
.section-head h2 em, .contact-title em { color: var(--accent); }

/* ---------- bento ---------- */
.bento { display: grid; gap: 14px; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(170px, auto); }
.tile {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 24px;
  background: var(--tile); border: 1px solid var(--line);
  transition: border-color .3s, background .3s; display: flex; flex-direction: column;
}
.tile:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.spotlight::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 50%);
}
.spotlight:hover::before { opacity: 1; }
.tile-label {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.tile-about { grid-column: span 4; grid-row: span 2; }
.about-text {
  font-family: var(--serif); font-weight: 300; font-size: clamp(1.3rem, 2.3vw, 1.75rem); line-height: 1.4;
  letter-spacing: -.015em; margin: 0 0 auto;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.chip { padding: 6px 14px; border-radius: 999px; font-size: .8rem; background: color-mix(in srgb, var(--sage) 14%, transparent); color: var(--fg); }

.tile-clock { grid-column: span 2; }
.clock { display: flex; align-items: center; gap: 18px; flex: 1; }
.clock-face { width: 86px; height: 86px; flex: none; }
.clock-ring { fill: var(--bg-2); stroke: var(--line); stroke-width: 1.5; }
#ticks line { stroke: var(--muted); stroke-width: 1.2; opacity: .5; }
.hand { stroke-linecap: round; transform-origin: 50px 50px; }
.hand.h { stroke: var(--fg); stroke-width: 3.5; }
.hand.m { stroke: var(--fg); stroke-width: 2.2; }
.hand.s { stroke: var(--clay); stroke-width: 1.2; }
.hub { fill: var(--clay); }
.clock-digital { font-family: var(--serif); font-size: 1.8rem; font-weight: 300; letter-spacing: -.02em; line-height: 1.1; }
.clock-loc { color: var(--muted); font-size: .85rem; }

.tile-now { grid-column: span 2; }
.now-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.now-list li { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.now-list .ico { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--tile-hover); font-size: .78rem; }

.tile-github { grid-column: span 2; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }
.gh-stats { display: flex; gap: 28px; margin-bottom: auto; }
.gh-stats strong { display: block; font-family: var(--serif); font-weight: 300; font-size: 2.4rem; letter-spacing: -.03em; line-height: 1.05; }
.gh-stats span { color: var(--muted); font-size: .8rem; }
.gh-latest {
  display: flex; justify-content: space-between; align-items: center; margin-top: 16px;
  padding: 10px 14px; border-radius: 12px; background: var(--tile-hover); transition: background .2s;
}
.gh-latest:hover { background: var(--sand); }

.tile-stack { grid-column: span 4; gap: 10px; justify-content: center; }
.marquee { overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.marquee-track { display: flex; gap: 10px; width: max-content; animation: marquee 40s linear infinite; }
.marquee.reverse .marquee-track { animation-direction: reverse; animation-duration: 46s; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }
.pill {
  white-space: nowrap; padding: 9px 16px; border-radius: 999px; background: var(--tile-hover);
  font-size: .88rem; display: inline-flex; align-items: center; gap: 8px;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.tile-stats { grid-column: span 3; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: auto; }
.stats strong { display: block; font-family: var(--serif); font-weight: 300; font-size: clamp(2.2rem, 4vw, 3rem); letter-spacing: -.04em; line-height: 1; }
.stats span { color: var(--muted); font-size: .8rem; }

.tile-contact {
  grid-column: span 3; justify-content: space-between; color: #fbf3ea; border: 0; background: #7a2238;
}
.tile-contact::after {
  content: ""; position: absolute; right: -40px; bottom: -80px; width: 200px; height: 240px;
  border-radius: 100px 100px 0 0; background: rgba(217,165,168,.22); pointer-events: none;
}
.tile-contact .tile-label { color: rgba(251,246,238,.75); }
.tile-contact p { font-family: var(--serif); font-weight: 300; font-size: 1.7rem; letter-spacing: -.02em; line-height: 1.2; margin: 0 0 18px; }
.tile-contact .btn { align-self: flex-start; position: relative; z-index: 1; }

/* ---------- projects ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }
.filter {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  font-size: .85rem; color: var(--muted); transition: all .2s;
}
.filter:hover { color: var(--fg); border-color: var(--fg); }
.filter.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 40px 24px; perspective: 1400px; }
.project { position: relative; display: block; transition: transform .25s ease-out; }
.project.hide { display: none; }
.project-media { aspect-ratio: 16/10; position: relative; overflow: hidden; border-radius: var(--radius); }
.project-media .art { position: absolute; inset: 0; width: 100%; height: 100%; transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.project:hover .project-media .art { transform: scale(1.04); }
.project-body { padding: 18px 2px 0; }
.project-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.project h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.55rem; letter-spacing: -.02em; }
.project .year { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.project p { color: var(--muted); margin: 6px 0 12px; font-size: .95rem; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: .75rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.project .arrow {
  position: absolute; top: 16px; right: 16px; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-2); color: var(--fg);
  transform: scale(.6) rotate(-45deg); opacity: 0; transition: all .4s cubic-bezier(.2,.8,.2,1); z-index: 2;
}
.project:hover .arrow { transform: scale(1) rotate(0); opacity: 1; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { border-top: 1px solid var(--line); }
.tl-item:last-child { border-bottom: 1px solid var(--line); }
.tl-card {
  display: grid; grid-template-columns: 200px 1fr auto; gap: 6px 20px; padding: 26px 4px;
  transition: background .3s, padding .3s;
}
.tl-card:hover { background: var(--tile); padding-left: 16px; padding-right: 16px; }
.tl-date { font-family: var(--mono); font-size: .75rem; color: var(--muted); padding-top: 6px; grid-column: 1; grid-row: 1; }
.tl-card > div:first-child { grid-column: 2; }
.tl-role { font-family: var(--serif); font-weight: 400; font-size: 1.4rem; letter-spacing: -.015em; line-height: 1.25; }
.tl-org { color: var(--sage); font-size: .92rem; }
.tl-desc { grid-column: 2 / -1; color: var(--muted); margin: 4px 0 0; font-size: .95rem; max-width: 60ch; }

/* ---------- contact ---------- */
.contact { padding-bottom: 70px; }
.contact-card {
  position: relative; overflow: hidden; text-align: center; border-radius: 28px;
  padding: clamp(56px, 9vw, 100px) 24px; background: var(--sand);
}
:root[data-theme="dark"] .contact-card { background: var(--tile); border: 1px solid var(--line); }
.contact-card::before, .contact-card::after {
  content: ""; position: absolute; border-radius: 999px 999px 0 0; pointer-events: none;
}
.contact-card::before { left: -50px; bottom: -40px; width: 180px; height: 220px; background: var(--sage); opacity: .55; }
.contact-card::after { right: -30px; bottom: -60px; width: 140px; height: 200px; background: var(--plum); opacity: .45; }
.contact-card > * { position: relative; z-index: 1; }
.contact-title { margin: 16px auto 34px; max-width: 13em; }
.contact .hero-cta { justify-content: center; }
.socials { display: flex; gap: 22px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.social { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; color: var(--muted); transition: color .2s; }
.social:hover { color: var(--accent); }
.social svg { width: 15px; height: 15px; }

.footer {
  width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 40px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted);
}

/* ---------- palette ---------- */
.palette {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: start center; padding: 14vh 16px 0;
  background: rgba(43,36,32,.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade .15s ease;
}
.palette[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.palette-box {
  width: min(540px, 100%); border-radius: 16px; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--line); box-shadow: 0 30px 80px -20px rgba(43,36,32,.35);
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { transform: scale(.97) translateY(-6px); opacity: 0; } }
#paletteInput {
  width: 100%; border: 0; outline: 0; background: transparent; color: var(--fg);
  font: 1rem var(--sans); padding: 18px 20px; border-bottom: 1px solid var(--line);
}
#paletteList { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow: auto; }
#paletteList li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: .92rem; }
#paletteList li .ico { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--tile-hover); }
#paletteList li .grp { margin-left: auto; color: var(--muted); font-size: .72rem; font-family: var(--mono); }
#paletteList li[aria-selected="true"] { background: var(--tile-hover); }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; z-index: 300;
  padding: 11px 18px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: .88rem;
  transition: all .35s cubic-bezier(.2,.8,.2,1); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .9s cubic-bezier(.2,.8,.2,1), transform .9s cubic-bezier(.2,.8,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .tile-about, .tile-stack, .tile-stats, .tile-contact, .tile-now { grid-column: span 2; }
  .tile-clock, .tile-github { grid-column: span 1; }
  .tile-about { grid-row: auto; }
  .hero-shape { opacity: .5; }
  .section-head { grid-template-columns: 1fr; gap: 10px; }
  .tl-card { grid-template-columns: 1fr; }
  .tl-date, .tl-card > div:first-child, .tl-desc { grid-column: 1; grid-row: auto; }
  .tl-date { padding-top: 0; }
}
@media (max-width: 720px) {
  .nav-links { display: none; }
  .projects { grid-template-columns: 1fr; }
  .bento { grid-template-columns: 1fr; }
  .tile-about, .tile-stack, .tile-stats, .tile-contact, .tile-clock, .tile-now, .tile-github { grid-column: span 1; }
  .hero { align-items: flex-end; padding-bottom: 120px; }
  .hero-shape { top: 90px; transform: none; right: -20px; width: 62vw; opacity: .55; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
