html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  --bg: #FBFAF7;
  --ink: #211F1C;
  --muted: #6F6A5E;
  --soft: #8A857A;
  --line: #ECE8DE;
  --line2: #E3DCCD;
  --card: #FFFFFF;
  --card-hover: #FFFDF8;
  --accent: #B4552D;
  --pill-bg: #F7EDE6;
  --pill2-bg: #F1EEE6;
  --hover-border: #D9B294;
  --hover-shadow: 0 8px 22px rgba(180, 85, 45, 0.12);
  --glow: rgba(180, 85, 45, 0.3);
  background: var(--bg);
  color: var(--ink);
  font-family: 'Newsreader', serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

body.dark {
  --bg: #16130F;
  --ink: #EBE6DA;
  --muted: #A79F8E;
  --soft: #8D8574;
  --line: #2A251E;
  --line2: #332D24;
  --card: #1E1A15;
  --card-hover: #25201A;
  --accent: #DB8551;
  --pill-bg: #372417;
  --pill2-bg: #2A251E;
  --hover-border: #6E4525;
  --hover-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  --glow: rgba(219, 133, 81, 0.35);
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line2);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: all 0.15s ease;
}

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

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 84px 24px 100px;
}

/* Header */

header {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.headshot {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  box-shadow: 0 0 0 1px var(--line2), 0 0 0 5px var(--card), 0 2px 10px rgba(33, 31, 28, 0.12);
}

.header-text {
  flex: 1;
  min-width: 220px;
}

h1 {
  font-size: clamp(26px, 5.5vw, 31px);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.subline {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 14px;
  color: var(--soft);
  margin: 5px 0 0;
}

nav {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 13.5px;
  display: flex;
  gap: 16px;
  align-items: center;
  align-self: center;
}

nav a {
  text-decoration: none;
  color: var(--muted);
}

nav a:hover {
  color: var(--accent);
}

.theme-toggle {
  border: 1px solid var(--line2);
  background: none;
  border-radius: 99px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--soft);
  padding: 0;
  transition: all 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Ambient sound — glowing spark button + soundscape menu */

.ambient-btn {
  border: 1px solid var(--line2);
  background: var(--pill-bg);
  border-radius: 99px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--accent);
  padding: 0;
  box-shadow: 0 0 8px var(--glow);
  animation: amb-pulse 3.6s ease-in-out infinite;
  transition: all 0.2s ease;
}

.ambient-btn:hover {
  border-color: var(--accent);
}

.ambient-btn.playing {
  border-color: var(--hover-border);
  box-shadow: 0 0 14px var(--glow), 0 0 30px var(--glow);
  animation: amb-pulse 1.8s ease-in-out infinite;
}

@keyframes amb-pulse {
  0%, 100% { box-shadow: 0 0 6px var(--glow); }
  50% { box-shadow: 0 0 14px var(--glow); }
}

.project-dialog--ambient {
  width: min(420px, calc(100vw - 40px));
}

.amb-list {
  padding: 8px;
}

.amb-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 12px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.amb-row:hover {
  background: var(--card-hover);
}

.amb-row.active {
  background: var(--pill2-bg);
}

.amb-glyph {
  font-family: 'Newsreader', serif;
  font-size: 14px;
  color: var(--soft);
  flex: none;
  width: 18px;
  text-align: center;
}

.amb-row.active .amb-glyph {
  color: var(--accent);
}

.amb-name {
  font-family: 'Newsreader', serif;
  font-size: 18px;
  font-weight: 600;
  font-style: italic;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.amb-hint {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--soft);
}

.amb-row--silence {
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  margin-top: 4px;
  padding-top: 14px;
}

#amb-wash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0;
  transition: opacity 1.5s ease;
}

#amb-wash.on {
  opacity: 1;
  animation: amb-breathe 10s ease-in-out infinite;
}

@keyframes amb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* Ambient particles — ported from kanakaribi's AmbientVisuals */

#amb-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 41;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
  overflow: hidden;
}

#amb-particles.on {
  opacity: 1;
}

.amb-ripple {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(180, 225, 230, 0.55) 50%, transparent 100%);
  filter: blur(0.5px);
  animation: amb-ripple-drift linear infinite;
}

@keyframes amb-ripple-drift {
  0% { transform: translateX(-30vw); opacity: 0; }
  15% { opacity: 0.7; }
  85% { opacity: 0.7; }
  100% { transform: translateX(30vw); opacity: 0; }
}

.amb-mote {
  position: absolute;
  bottom: -8px;
  border-radius: 50%;
  background: rgba(232, 217, 184, 0.55);
  box-shadow: 0 0 6px rgba(232, 217, 184, 0.35);
  animation: amb-mote-rise linear infinite;
}

@keyframes amb-mote-rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 0.85; }
  50% { transform: translate(14px, -50vh); }
  90% { opacity: 0.85; }
  100% { transform: translate(-10px, -110vh); opacity: 0; }
}

.amb-meadow-haze {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(180, 200, 120, 0.04), transparent);
}

.amb-snow {
  position: absolute;
  top: -10px;
  border-radius: 50%;
  background: rgba(220, 235, 245, 0.7);
  box-shadow: 0 0 3px rgba(220, 235, 245, 0.4);
  animation: amb-snow-fall linear infinite;
}

@keyframes amb-snow-fall {
  0% { transform: translate(0, 0); opacity: 0; }
  8% { opacity: 0.9; }
  92% { opacity: 0.9; }
  100% { transform: translate(28px, 110vh); opacity: 0; }
}

.amb-rain {
  position: absolute;
  top: -60px;
  width: 1px;
  background: linear-gradient(180deg, transparent 0%, rgba(180, 205, 220, 0.32) 100%);
  transform: rotate(8deg);
  transform-origin: center top;
  animation: amb-rain-fall linear infinite;
}

@keyframes amb-rain-fall {
  0% { transform: translate(0, 0) rotate(8deg); opacity: 0; }
  15% { opacity: 0.45; }
  85% { opacity: 0.45; }
  100% { transform: translate(18px, 110vh) rotate(8deg); opacity: 0; }
}

.amb-ember {
  position: absolute;
  bottom: -8px;
  border-radius: 50%;
  background: #E8A87C;
  box-shadow: 0 0 8px rgba(232, 168, 124, 0.65);
  animation: amb-ember-rise linear infinite;
}

@keyframes amb-ember-rise {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  12% { opacity: 0.85; }
  60% { transform: translate(20px, -45vh) scale(0.9); opacity: 0.5; }
  100% { transform: translate(-15px, -85vh) scale(0.6); opacity: 0; }
}

.amb-hearth-glow {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 55%;
  background: radial-gradient(ellipse 80% 100% at 50% 100%, rgba(240, 140, 60, 0.08) 0%, rgba(240, 140, 60, 0.03) 40%, transparent 75%);
  animation: amb-hearth-flicker 5.5s ease-in-out infinite;
}

@keyframes amb-hearth-flicker {
  0%, 100% { opacity: 0.75; }
  35% { opacity: 1; }
  62% { opacity: 0.85; }
}

/* Light-mode particle visibility */

body:not(.dark) #amb-particles { mix-blend-mode: multiply; }
body:not(.dark) .amb-ripple { background: linear-gradient(90deg, transparent 0%, rgba(38, 118, 132, 0.55) 50%, transparent 100%); }
body:not(.dark) .amb-mote { background: rgba(150, 108, 48, 0.6); box-shadow: 0 0 6px rgba(150, 108, 48, 0.3); }
body:not(.dark) .amb-meadow-haze { background: linear-gradient(to top, rgba(120, 150, 55, 0.10), transparent); }
body:not(.dark) .amb-snow { background: rgba(96, 128, 165, 0.7); box-shadow: 0 0 3px rgba(96, 128, 165, 0.4); }
body:not(.dark) .amb-rain { background: linear-gradient(180deg, transparent 0%, rgba(64, 108, 145, 0.45) 100%); }
body:not(.dark) .amb-ember { background: #A8603A; box-shadow: 0 0 8px rgba(168, 96, 58, 0.6); }
body:not(.dark) .amb-hearth-glow { background: radial-gradient(ellipse 80% 100% at 50% 100%, rgba(200, 110, 40, 0.14) 0%, rgba(200, 110, 40, 0.06) 40%, transparent 75%); }

/* The Konark wheels always turn — imperceptibly slow at rest, faster with sound */

.divider .chakra {
  animation: chakra-turn 18s linear infinite;
}

body.amb-playing .divider .chakra {
  animation-duration: 7s;
}

@keyframes chakra-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-btn,
  #amb-wash.on,
  #amb-particles *,
  .divider .chakra {
    animation: none;
  }

  #amb-particles {
    display: none;
  }
}

/* External-link arrow — custom SVG, immune to emoji substitution */

.ext {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 0.3em;
  vertical-align: 0.08em;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2012%2012'%3E%3Cg%20fill='none'%20stroke='%23000'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M3.6%208.4L9.4%202.6'/%3E%3Cpath%20d='M4.8%202.6h4.6v4.6'/%3E%3C/g%3E%3Ccircle%20cx='2.3'%20cy='9.7'%20r='1.3'%20fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2012%2012'%3E%3Cg%20fill='none'%20stroke='%23000'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M3.6%208.4L9.4%202.6'/%3E%3Cpath%20d='M4.8%202.6h4.6v4.6'/%3E%3C/g%3E%3Ccircle%20cx='2.3'%20cy='9.7'%20r='1.3'%20fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
}

.card-title .ext,
.featured-title .ext {
  color: var(--accent);
  opacity: 0.85;
}

/* Dividers */

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 52px;
}

.divider--first {
  margin-top: 44px;
}

.divider--footer {
  margin-top: 60px;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: var(--line2);
}

.chakra {
  flex: none;
  opacity: 0.8;
  color: var(--accent);
}

/* Sections */

section {
  margin-top: 30px;
}

h2 {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--soft);
  margin: 0 0 16px;
}

h2.work-heading {
  margin-bottom: 4px;
}

/* About */

.motto {
  font-size: 17px;
  font-style: italic;
  color: var(--soft);
  margin: 0 0 14px;
}

#about-full p:not(.about-label) {
  font-size: 18px;
  line-height: 1.65;
  margin: 6px 0 0;
}

.about-label {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
  margin: 22px 0 0;
}

.collapse .about-label:first-child {
  margin-top: 14px;
}

/* About: summarize toggle */

.sum-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sum-head .motto {
  margin-bottom: 0;
}

.sum-btn {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--pill-bg);
  border: 1px solid transparent;
  border-radius: 99px;
  padding: 6px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  transition: all 0.2s ease;
}

.sum-btn:hover {
  border-color: var(--hover-border);
}

.sum-btn svg {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#about.summarized .sum-btn svg {
  transform: rotate(180deg);
}

.collapse {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}

.collapse > div {
  overflow: hidden;
}

.collapse.hidden {
  grid-template-rows: 0fr;
  opacity: 0;
}

.collapse.hidden > div {
  visibility: hidden;
}

.ledger-spacer {
  height: 8px;
}

.ledger-row {
  display: flex;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.ledger-row:last-child {
  border-bottom: none;
}

.ledger-label {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
  flex: none;
  width: 104px;
  padding-top: 3px;
}

.ledger-val {
  font-size: 16.5px;
  line-height: 1.5;
  margin: 0;
}

/* Work */

.work-row {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.work-row:last-child {
  border-bottom: none;
}

.work-line1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 16px;
  flex-wrap: wrap;
}

.work-company {
  font-size: 17px;
  font-weight: 600;
}

.work-years {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 13px;
  color: var(--soft);
}

.work-desc {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--muted);
  margin: 3px 0 0;
}

.highlights {
  margin: 12px 0 2px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.highlights li {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--muted);
}

.highlights .lead {
  color: var(--ink);
  font-weight: 500;
}

/* Cards (projects + featured) */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
  transition: all 0.18s ease;
}

.card:hover {
  border-color: var(--hover-border);
  background: var(--card-hover);
  box-shadow: var(--hover-shadow);
  transform: translateY(-3px);
}

.card--flat {
  padding: 16px 16px 15px;
}

.card[data-dialog] {
  cursor: pointer;
}

.card[data-dialog]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-media {
  height: 185px;
  border-bottom: 1px solid var(--line);
  display: block;
  width: 100%;
  background: var(--pill2-bg);
}

.card-media img,
.card-media video {
  width: 100%;
  height: 185px;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 15px 18px 16px;
}

.card-title {
  text-decoration: none;
  font-size: 17px;
  font-weight: 600;
}

.card-title:hover {
  color: var(--accent);
}

.card-desc {
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  margin: 6px 0 0;
}

.featured-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.featured-link {
  text-decoration: none;
  color: var(--ink);
}

.featured-link:hover .featured-title {
  color: var(--accent);
}

.lead-link {
  text-decoration-color: var(--line2);
}

.lead-link:hover .lead {
  color: var(--accent);
}

.featured-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  margin: 6px 0 0;
}

.pill {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 99px;
  padding: 3px 9px;
  display: inline-block;
  margin-top: 12px;
}

.pill--accent {
  color: var(--accent);
  background: var(--pill-bg);
}

.pill--neutral {
  color: var(--muted);
  background: var(--pill2-bg);
}

/* Art × Science mosaic */

.art-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.art-tile {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  cursor: pointer;
  aspect-ratio: 1;
  transition: all 0.18s ease;
}

.art-tile--wide {
  grid-column: span 2;
  aspect-ratio: 2.05;
}

.art-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.art-tile:hover {
  border-color: var(--hover-border);
  box-shadow: var(--hover-shadow);
  transform: translateY(-3px);
}

.art-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .art-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Footer */

footer {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 13px;
  color: var(--soft);
}

footer a {
  text-decoration: none;
  color: var(--soft);
}

footer a:hover {
  color: var(--accent);
}

/* Project detail dialogs */

.project-dialog {
  width: min(600px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  max-height: calc(100dvh - 76px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-family: 'Newsreader', serif;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.project-dialog::backdrop {
  background: rgba(22, 19, 15, 0.55);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}

.dialog-head h3 {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.dialog-close {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 18px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line2);
  border-radius: 99px;
  background: none;
  color: var(--soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dialog-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.dialog-media {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.dialog-media img,
.dialog-media video {
  width: 100%;
  height: 320px;
  object-fit: contain;
  display: block;
}

.dialog-body {
  padding: 16px 18px 18px;
}

.dialog-body p {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

.dialog-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.gallery-thumb {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.gallery-thumb:hover,
.gallery-thumb.active {
  border-color: var(--hover-border);
}

.gallery-thumb img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
}

.transcript-label {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--soft);
  margin: 16px 0 6px;
}

.transcript p {
  font-size: 14.5px;
  line-height: 1.55;
  font-style: italic;
  color: var(--muted);
  margin: 6px 0 0;
}

.transcript p span {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11px;
  font-style: normal;
  color: var(--soft);
  margin-right: 8px;
}

.dialog-links {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 14px;
}

.dialog-links a {
  text-decoration: none;
  color: var(--accent);
}

.dialog-links a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .collapse,
  .sum-btn svg {
    transition: none;
  }
}
