/* Pratham Bhalla - portfolio
   Apple HIG style: SF system stack (+ Mukta for Devanagari),
   generous whitespace, clear hierarchy. Dark by default. */

:root {
  --ease: cubic-bezier(.22, .61, .36, 1);
}

html[data-theme="dark"] {
  --bg: #101010;
  --bg-soft: #181817;
  --ink: #e8e8e4;
  --muted: #a2a29c;
  --faint: #6d6d68;
  --rule: rgba(232, 232, 228, .16);
  --card: rgba(232, 232, 228, .035);
}

html[data-theme="light"] {
  --bg: #f6f6f4;
  --bg-soft: #ececea;
  --ink: #1d1d1b;
  --muted: #5f5f5a;
  --faint: #98988f;
  --rule: rgba(29, 29, 27, .18);
  --card: rgba(29, 29, 27, .04);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.05rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .6s var(--ease), color .6s var(--ease);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem;
}

/* Top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: .5rem 0 2.5rem;
}

#theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
  font-family: inherit;
  font-size: .82rem;
  letter-spacing: .01em;
  padding: .4rem .9rem;
  cursor: pointer;
  transition: color .3s, border-color .3s;
}

#theme-toggle:hover {
  color: var(--ink);
  border-color: var(--faint);
}

.toggle-icon { font-size: .95rem; line-height: 1; }

html[data-theme="dark"] .toggle-icon::before { content: "\263E"; } /* crescent moon */
html[data-theme="dark"] .toggle-label::before { content: "after dark"; }
html[data-theme="light"] .toggle-icon::before { content: "\2600"; } /* sun */
html[data-theme="light"] .toggle-label::before { content: "by daylight"; }

/* Sections */

section { margin: 0; }

main > section + section { margin-top: 4.25rem; }

h2 {
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -.01em;
  color: var(--ink);
  margin: 0 0 1.1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Intro */

.intro p { margin: 0 0 1rem; }

/* Ledgers (experience, projects) */

.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ledger li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--rule);
}

.ledger li:last-child { border-bottom: 0; }

.year {
  color: var(--faint);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry strong { font-weight: 600; }

.entry a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: .18em;
  transition: text-decoration-color .3s;
}

.entry a:hover { text-decoration-color: var(--ink); }

.note {
  display: block;
  color: var(--muted);
  font-style: italic;
  font-size: .92rem;
}

/* Commonplace book quotes: quiet carousel, one quote at a time */

.commonplace { text-align: left; }

.commonplace .slide {
  margin: 0;
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.5;
  letter-spacing: -.005em;
}

html:not(.js) .commonplace .slide + .slide { margin-top: 2.4rem; }

.commonplace .slide p { margin: 0 0 .6rem; white-space: pre-line; }

.commonplace .slide p::before { content: "\201C"; color: var(--faint); }
.commonplace .slide p::after { content: "\201D"; color: var(--faint); }

.commonplace .slide p[lang="hi"] {
  font-family: "Mukta", -apple-system, BlinkMacSystemFont, sans-serif;
  font-style: normal;
  font-weight: 300;
}

.commonplace cite {
  display: block;
  font-size: .85rem;
  font-style: normal;
  color: var(--muted);
}

.commonplace cite::before { content: "\2014 "; }

.commonplace .caption {
  margin: 2.4rem 0 0;
  color: var(--faint);
  font-style: italic;
  font-size: .85rem;
}

/* Carousel: slides stacked in one cell, cross-fading; small dot controls */

.js .commonplace .slides {
  display: grid;
  touch-action: pan-y; /* vertical page scroll wins; horizontal swipes reach the carousel */
}

.js .commonplace .slide {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s var(--ease), visibility 0s linear 1s;
}

.js .commonplace .slide.active {
  position: relative;
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: opacity 1s var(--ease), visibility 0s;
}

.carousel-dots { display: none; }

.js .carousel-dots {
  display: flex;
  gap: 0;
  align-items: center;
  margin-top: 1.6rem;
}

.carousel-dots .dot {
  width: 34px; /* invisible hit area: 34px tap target */
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.carousel-dots .dot::before {
  content: "";
  width: 6px; /* the visible dot: fixed size, independent of the hit area */
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .35;
  transition: opacity .3s;
}

.carousel-dots .dot:hover::before { opacity: .8; }

.carousel-dots .dot.active::before {
  opacity: 1;
  background: var(--ink);
}

.carousel-dots .dot:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: 3px;
}

.carousel-dots .dot:focus-visible::before { opacity: 1; }

/* Footer */

footer {
  margin-top: 3.5rem;
  text-align: left;
  color: var(--faint);
  font-size: .88rem;
}

footer p { margin: .2rem 0; }
footer .colophon { font-style: italic; font-size: .8rem; }

/* Small screens */

@media (max-width: 560px) {
  body { font-size: 1rem; }
  .page { padding: 1rem 1.25rem 3rem; }
  .commonplace .slide { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* Descriptions use .note under titles (already styled) */

/* Fixed top music player */
.player {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: 52px;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 0 max(1rem, calc((100vw - 42rem) / 2 + 1.5rem));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--rule);
  position: fixed;
}
.page { padding-top: 4.5rem; }
.pbtn {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%;
  color: var(--muted); cursor: pointer; padding: 0;
  transition: color .3s, background-color .3s;
}
.pbtn:hover { color: var(--ink); background: var(--card); }
.pbtn svg { width: 16px; height: 16px; fill: currentColor; }
.pbtn.main { color: var(--ink); border: 1px solid var(--rule); }
.pbtn.main svg { width: 14px; height: 14px; }
.pbtn .i-pause { display: none; }
.player.playing .i-play { display: none; }
.player.playing .i-pause { display: block; }
.pmeta { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; margin: 0 .5rem; line-height: 1.2; }
.ptitle { font-size: .82rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.partist { font-size: .72rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbar { flex: 0 0 min(28%, 9rem); height: 18px; display: flex; align-items: center; cursor: pointer; }
.pbar::before { content: ""; position: absolute; width: inherit; }
.pbar { position: relative; }
.pbar { background: linear-gradient(var(--rule), var(--rule)) center / 100% 2px no-repeat; }
.pbar span { display: block; height: 2px; width: 0; background: var(--ink); border-radius: 2px; }
#yt-host { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
@media (max-width: 560px) { .pbar { flex-basis: 3.5rem; } .player { padding: 0 .75rem; } }

/* Read shelf: one row, free horizontal scroll, no visible controls */
.shelf { overflow: hidden; }
.books {
  list-style: none; margin: 0 calc(-1 * max(1.25rem, (100vw - 42rem) / 2 + 1.5rem)); padding: 0 max(1.25rem, calc((100vw - 42rem) / 2 + 1.5rem)) .25rem;
  display: flex; gap: 1.1rem; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  touch-action: pan-x pan-y; cursor: grab; outline: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 1.25rem, #000 calc(100% - 1.25rem), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 1.25rem, #000 calc(100% - 1.25rem), transparent 100%);
}
.books::-webkit-scrollbar { display: none; width: 0; height: 0; }
.books.drag { cursor: grabbing; user-select: none; }
.book { flex: none; width: 6.4rem; display: flex; flex-direction: column; }
.book img, .book .nocover {
  width: 6.4rem; height: 9.6rem; object-fit: cover; border-radius: 3px;
  background: var(--bg-soft); box-shadow: 0 0 0 1px var(--rule);
  -webkit-user-drag: none; user-select: none;
}
.book .nocover { display: grid; place-items: center; font-size: 2rem; color: var(--faint); }
.bt { margin-top: .55rem; font-size: .78rem; font-weight: 600; line-height: 1.3; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ba { margin-top: .15rem; font-size: .72rem; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
