/* ==========================================================
   Jamie Shih — portfolio
   Colors are tokens: edit them here to re-theme the whole site.
   ========================================================== */
:root {
  --bg: #f8f7fb;
  --surface: #ffffff;
  --surface-2: #efedf6;
  --text: #1b1a22;
  --muted: #625f70;
  --line: #e3e0ec;
  --accent: #6c4ccf;        /* purple */
  --accent-2: #3f7fd6;      /* cool blue, secondary */
  --accent-soft: #ebe5fb;
  --shadow: 0 1px 2px rgba(30, 20, 60, .05), 0 8px 24px rgba(30, 20, 60, .07);

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121118; --surface: #1a1922; --surface-2: #23212d; --text: #eeecf5;
    --muted: #a19db3; --line: #2e2b3a; --accent: #a98cf6; --accent-2: #7eaaf0;
    --accent-soft: #2b2342; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121118; --surface: #1a1922; --surface-2: #23212d; --text: #eeecf5;
  --muted: #a19db3; --line: #2e2b3a; --accent: #a98cf6; --accent-2: #7eaaf0;
  --accent-soft: #2b2342; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
strong { font-weight: 600; }
::selection { background: var(--accent-soft); }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

h1, h2, h3 { line-height: 1.15; font-weight: 600; }
h1, h2 { font-family: var(--serif); letter-spacing: -.01em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); }
h3 { font-size: 1.1rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .75rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5em;
  padding: .75em 1.3em;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  font-size: .95rem;
  text-decoration: none;
  border: 1px solid var(--text);
  transition: transform .15s ease, background .2s, color .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--text); }
.btn--small { padding: .45em 1em; font-size: .88rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.nav__logo { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; text-decoration: none; }
.nav__links { display: flex; align-items: center; gap: 1.6rem; }
.nav__links > a:not(.btn) { text-decoration: none; font-size: .93rem; color: var(--muted); transition: color .2s; }
.nav__links > a:not(.btn):hover { color: var(--text); }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

.nav__toggle { display: none; background: none; border: 0; width: 40px; height: 40px; cursor: pointer; position: relative; }
.nav__toggle span { position: absolute; left: 10px; right: 10px; height: 2px; background: var(--text); transition: transform .25s; }
.nav__toggle span:first-child { top: 15px; }
.nav__toggle span:last-child { top: 23px; }
.nav__toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
  padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(3rem, 7vw, 5rem);
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 400; margin-bottom: 1.25rem; }
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 36em; }
.lede strong { color: var(--text); }
.hero__cta { display: flex; flex-wrap: wrap; gap: .75rem; margin: 2rem 0 1.75rem; }
.hero__meta { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .88rem; color: var(--muted); }
.hero__meta li { display: flex; align-items: center; gap: .5em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot--live { background: #3fb67a; box-shadow: 0 0 0 4px color-mix(in srgb, #3fb67a 22%, transparent); }

.hero__photo { position: relative; justify-self: end; width: min(380px, 100%); }
.hero__photo::before {
  content: ""; position: absolute; inset: 18px -18px -18px 18px;
  border-radius: 24px; background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.hero__photo img {
  position: relative; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 30%;
  border-radius: 24px; box-shadow: var(--shadow);
}

/* ---------- Sections ---------- */
.section { padding: clamp(3.5rem, 8vw, 6rem) 0; border-top: 1px solid var(--line); }
.section__head { margin-bottom: 2.5rem; }
.section__sub { color: var(--muted); margin-top: .75rem; max-width: 40em; }
.section__sub a { color: var(--accent); text-underline-offset: 3px; }

/* About */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 3rem; align-items: start; }
.about__body p + p { margin-top: 1rem; }
.about__body p { color: var(--muted); }
.about__body strong { color: var(--text); }
.facts { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1.5rem; box-shadow: var(--shadow); }
.facts div { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.facts dd { font-weight: 500; margin-top: .15rem; }

/* Timeline */
.timeline { list-style: none; }
.job {
  display: grid; grid-template-columns: 180px 1fr; gap: 2rem;
  padding: 2rem 0; border-bottom: 1px solid var(--line);
}
.job:first-child { padding-top: 0; }
.job:last-child { border-bottom: 0; }
.job__when { font-family: var(--mono); font-size: .82rem; color: var(--muted); padding-top: .2rem; }
.job h3 { font-size: 1.15rem; margin-bottom: .6rem; }
.job h3 span { font-weight: 400; color: var(--muted); }
.job ul { padding-left: 1.1rem; color: var(--muted); }
.job li { margin: .3rem 0; }
.job li::marker { color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.tags span, .chips span {
  font-family: var(--mono); font-size: .74rem;
  padding: .3em .75em; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}

/* Projects */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card--feature { grid-column: 1 / -1; flex-direction: row; }
.card--feature .card__media { flex: 1 1 50%; min-height: 260px; height: auto; }
.card--feature .card__body { flex: 1 1 50%; align-self: center; }
.card__media { height: 180px; background: var(--surface-2); position: relative; overflow: hidden; }
.card__media img, .card__media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__media svg { width: 100%; height: 100%; }
.card__body { padding: 1.5rem 1.6rem 1.75rem; }
.card__kicker { font-family: var(--mono); font-size: .74rem; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem; }
.card h3 { font-family: var(--serif); font-size: 1.45rem; margin-bottom: .6rem; }
.card p { color: var(--muted); font-size: .96rem; }
.card__link { display: inline-block; margin-top: 1rem; font-weight: 500; color: var(--accent); text-decoration: none; }

/* Illustrations inside project cards */
.card__media--wave { background:
  linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 25%,
  var(--surface-2); }
.wave path { fill: none; stroke: var(--accent-2); stroke-width: 2; }
.wave path.hi { stroke: var(--accent); }
.wave text { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.wave text.lbl { font-size: 10px; fill: var(--text); }
.card__media--grid { background: radial-gradient(var(--line) 1.2px, transparent 1.2px) 0 0 / 16px 16px, var(--surface-2); }
.seg path { stroke: var(--accent); stroke-width: 9; stroke-linecap: round; fill: none; }
.card__media--bode .axis { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.card__media--bode .curve { fill: none; stroke: var(--accent-2); stroke-width: 3; }
.card__media--bode circle { fill: var(--bg); stroke: var(--accent); stroke-width: 2.5; }
.card__media--bode text { font-family: var(--mono); font-size: 13px; fill: var(--muted); }
.card__media--pcb .board { fill: color-mix(in srgb, #2f8f5b 22%, var(--surface-2)); stroke: #2f8f5b; stroke-width: 1.5; }
.card__media--pcb .trace { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linejoin: round; }
.card__media--pcb circle { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }

/* Light show + video editing cards */
.card--reverse { flex-direction: row-reverse; }
.card__links { margin-top: 1rem; }
.card__link:hover { text-decoration: underline; text-underline-offset: 3px; }
.faq a { color: var(--accent); text-underline-offset: 3px; }
.card__media--stage { background: #0b0a10; }
.beams path { mix-blend-mode: screen; opacity: .55; animation: pulse 4s ease-in-out infinite; }
.beams .b1 { fill: #8b5cf6; }
.beams .b2 { fill: #3f7fd6; animation-delay: -1s; }
.beams .b3 { fill: #d946ef; animation-delay: -2s; }
.beams .b4 { fill: #22c3d6; animation-delay: -3s; }
.fixtures rect { fill: #2b2a33; stroke: #55526a; }
.dmx text { font-family: var(--mono); font-size: 11px; fill: #9a96b0; }
@keyframes pulse { 0%, 100% { opacity: .15; } 50% { opacity: .7; } }

/* Video editing reel */
.card--wide { margin-top: 1.5rem; }
.card--wide .card__body { padding: 1.75rem 1.75rem 2rem; }
.card--wide > .card__body > p:not(.tags):not(.card__links):not(.card__kicker) { max-width: 44em; }
.reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.5rem; }
.reel {
  position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: 12px; background: #000; text-decoration: none; color: #fff;
  border: 1px solid var(--line);
}
.reel video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.reel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.75), transparent 55%); pointer-events: none; }
.reel__cap { position: absolute; left: 14px; bottom: 12px; z-index: 1; display: flex; flex-direction: column; line-height: 1.3; }
.reel__cap strong { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.reel__cap span { font-family: var(--mono); font-size: .72rem; opacity: .8; }
.reel__play {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  font-size: .75rem; font-weight: 500; padding: .35em .8em; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 85%, transparent); color: #fff;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s;
}
.reel:hover video { transform: scale(1.04); }
.reel:hover .reel__play, .reel:focus-visible .reel__play { opacity: 1; transform: none; }
@media (hover: none) { .reel__play { opacity: 1; transform: none; } }
@media (max-width: 760px) { .reels { grid-template-columns: 1fr; } }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.skill-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.skill-group h3 { font-size: 1rem; margin-bottom: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chips span { font-size: .8rem; color: var(--text); background: var(--surface-2); }
.chips--quiet span { color: var(--muted); }

/* Education + leadership */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; }
.edu__degree { font-size: 1.15rem; font-weight: 600; }
.edu__degree span { font-weight: 400; color: var(--muted); }
.edu__when { font-family: var(--mono); font-size: .82rem; color: var(--muted); margin: .4rem 0 1.5rem; }
.edu__label { font-size: .9rem; font-weight: 600; margin-bottom: .6rem; }
.lead { list-style: none; }
.lead li { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.lead li:first-child { padding-top: 0; }
.lead li:last-child { border-bottom: 0; }
.lead strong { display: block; }
.lead span { color: var(--muted); font-size: .95rem; }

/* FAQ */
.faq { display: grid; gap: .75rem; max-width: 780px; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
summary {
  cursor: pointer; list-style: none; padding: 1.1rem 1.4rem;
  font-weight: 500; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-family: var(--mono); font-size: 1.2rem; color: var(--accent); transition: transform .2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { padding: 0 1.4rem 1.3rem; color: var(--muted); }

/* Contact */
.contact { text-align: center; }
.contact h2 { font-size: clamp(2rem, 5vw, 3rem); }
.contact .section__sub { margin-inline: auto; }
.contact__links { display: flex; justify-content: center; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

/* Footer */
.footer {
  display: flex; justify-content: space-between; padding: 2rem 0 3rem;
  border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted);
}
.footer a { text-decoration: none; }
.footer a:hover { color: var(--text); }

/* Reveal animation */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .beams path { animation: none; opacity: .45; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .card, .btn { transition: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .about, .two-col { grid-template-columns: 1fr; gap: 2.5rem; }
  .skills, .projects { grid-template-columns: 1fr 1fr; }
  .card--reverse { flex-direction: column; }
  .card--feature { flex-direction: column; }
  .card--feature .card__media { min-height: 200px; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .nav__toggle { display: block; }
  .nav__links {
    position: absolute; top: 68px; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    padding: .5rem 16px 1.25rem;
    background: var(--bg); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav__links.open { display: flex; }
  .nav__links > a:not(.btn) { padding: .7rem 0; width: 100%; font-size: 1rem; }
  .nav__links .btn { margin: .5rem 0; }

  .hero { grid-template-columns: 1fr; padding-top: 2rem; }
  .hero__photo { order: -1; justify-self: start; width: min(240px, 70%); }
  .projects, .skills { grid-template-columns: 1fr; }
  .job { grid-template-columns: 1fr; gap: .4rem; }
  .footer { flex-direction: column; gap: .5rem; }
}
