:root {
  --bg: #000;
  --text: #f5f5f7;
  --muted: rgba(225, 228, 255, 0.72);
  --faint: rgba(235, 235, 245, 0.5);
  --line: rgba(255, 255, 255, 0.14);
  --glass: rgba(30, 31, 36, 0.62);
  --blue: #0a84ff;
}

* { box-sizing: border-box; }

html { background: var(--bg); transition: background-color 0.3s; }

/* light switch on (bg.js): the sheet turns light grey, so the page and its text flip to a light theme */
:root[data-light] { --bg: #eef1f2; }
:root[data-light] main, :root[data-light] .hud, :root[data-light] .contact {
  --text: #14171a;
  --muted: rgba(20, 24, 28, 0.72);
  --faint: rgba(20, 24, 28, 0.55);
  --line: rgba(0, 0, 0, 0.14);
}
:root[data-light] main { color: var(--text); } /* re-applies the inherited text colour from the swapped variables */
:root[data-light] .hud { background-color: rgba(255, 255, 255, 0.55); box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.1); }
:root[data-light] .hud:hover { background-color: rgba(255, 255, 255, 0.8); }
:root[data-light] .badge { background: rgba(0, 0, 0, 0.07); color: var(--muted); }
:root[data-light] .badge.green { background: rgba(36, 138, 61, 0.14); color: #1f7a36; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  transition: background-color 0.3s;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}

body:has(dialog[open]) { overflow: hidden; }

a { color: inherit; text-decoration: none; }

/* dragging belongs to the bubble sheet, not to ghost copies of links and pictures */
a, img { -webkit-user-drag: none; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 10px; }

/* ---------- 3D background (bg.js) ---------- */

.bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 18%, rgba(0,0,0,.35) 45%, #000 80%);
          mask-image: linear-gradient(to bottom, transparent 18%, rgba(0,0,0,.35) 45%, #000 80%);
}

/* cursor over the empty page: pop a bubble or drag the sheet (set by bg.js) */
:root[data-bg="pop"] { cursor: pointer; }
:root[data-bg="grab"] { cursor: grab; }
:root[data-bg="grabbing"], :root[data-bg="grabbing"] * { cursor: grabbing; }

/* ---------- Corner controls (bg.js): pop counter on the left, sound on the right ---------- */

.hud {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  height: 36px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
          backdrop-filter: blur(20px) saturate(1.6);
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}
.hud::after { content: ""; position: absolute; inset: -4px; } /* 44px touch target around a 36px pill */
.hud:hover { color: var(--text); background-color: rgba(255, 255, 255, 0.1); }
.hud[hidden] { display: none; }
.hud svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.counter { left: 16px; pointer-events: none; } /* just a readout: clicks fall through to the bubbles */

/* at 10, 50 and every 100 pops (bg.js): a notification that drops in at the top, and confetti */
.note {
  position: fixed;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  z-index: 4; /* above the confetti, so the text stays readable */
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 14px 28px;
  border-radius: 22px;
  text-align: center;
  background: rgba(30, 31, 36, 0.92);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(20px);
          backdrop-filter: blur(20px);
  color: #f5f5f7;
  font-size: 1rem;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.3s, transform 0.45s cubic-bezier(.3, 1.4, .5, 1); /* a small overshoot, like a notification dropping in */
}
.note strong { display: block; font-size: 1.5rem; font-weight: 700; }
.note.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; z-index: 3; width: 7px; height: 11px; border-radius: 2px; pointer-events: none; }
.sound { right: 16px; padding: 0; }
.light { right: 60px; padding: 0; }
/* on: a solid white tile with a dark filled bulb, like a Control Center toggle (:root[data-light] beats the light-theme .hud rules) */
:root[data-light] .light[aria-pressed="true"] { background-color: #fff; color: #14171a; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16); }
.light[aria-pressed="true"] .bulb { fill: currentColor; }
.hud:focus-visible { outline-offset: 2px; }
.sound[aria-pressed="true"] .mute, .sound[aria-pressed="false"] .waves { display: none; }

/* ---------- Layout ---------- */

main {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  max-width: 640px;
  margin: 0 auto;
  padding: max(56px, 9vh) 24px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.intro { text-align: center; }
/* boxes hug the text, so the empty space beside the name is sheet you can drag */
.intro h1, .intro .bio { width: fit-content; margin-inline: auto; }

.photo {
  display: block;
  width: 128px;
  height: 128px;
  margin: 0 auto 28px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line);
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.bio {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(1.0625rem, 2.6vw, 1.25rem);
  line-height: 1.45;
  text-wrap: balance;
}

/* ---------- Projects ---------- */

.rule {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 48px 0 8px;
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rule.soon { margin: 8px 0 0; } /* closes the list the way "Shipped" opens it */

.project {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 20px;
  align-items: start;
  padding: 22px 12px;
  margin: 0 -12px;
  border-radius: 20px;
  transition: background-color 0.2s;
}

/* divider drawn as a background so the hover fill keeps its rounded corners */
.project + .project { background: linear-gradient(var(--line), var(--line)) top center / calc(100% - 24px) 1px no-repeat; }
.project:hover { background-color: rgba(255, 255, 255, 0.04); }

.icon {
  width: 84px;
  height: 84px;
  border-radius: 22.5%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.text, .go { grid-column: 2; grid-row: 1; }
.text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* the link label sits in the title row's top-right corner; reserve room for it */
.title { padding-right: 40px; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.store .title { padding-right: 120px; }

.desc { color: var(--muted); font-size: 1rem; line-height: 1.4; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(235, 235, 245, 0.85);
  font-size: 0.8125rem;
}

.badge.green { background: rgba(48, 209, 88, 0.14); color: #63e083; }

.go {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-self: end;
  padding-top: 2px;
  color: var(--muted);
  font-size: 0.9375rem;
  white-space: nowrap;
}

.arrow {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}

.project:hover .arrow { transform: translate(2px, -2px); }

/* ---------- CTA + footer ---------- */

.cta { margin-top: auto; padding-top: 56px; text-align: center; }

.contact-btn, .send {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
}

.contact-btn {
  padding: 13px 30px;
  border: 1px solid #fff;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color: #0b0b0f;
  font-size: 1.0625rem;
  font-weight: 500;
}

.contact-btn:hover { background: #e9ecf2; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 28px rgba(10, 132, 255, 0.3); }
/* light theme: apple.com's button blue (#0071e3 keeps white text above 4.5:1 contrast; system #007aff doesn't) */
:root[data-light] .contact-btn { border-color: #0071e3; background: #0071e3; color: #fff; }
:root[data-light] .contact-btn:hover { background: #0077ed; }
.contact-btn:active, .send:active { transform: scale(0.97); }

/* 1fr auto 1fr keeps the dot on the page's center line whatever the link widths */
footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.9375rem;
}

footer a { display: inline-flex; align-items: center; gap: 4px; transition: color 0.2s; }
footer a:first-child { justify-self: end; }
footer a:last-child { justify-self: start; }
footer a:hover { color: var(--text); }
.arrow.sm { width: 15px; height: 15px; stroke-width: 2; }
.dot { color: var(--faint); }
.heart { font-variant-emoji: text; }

/* ---------- Contact dialog ---------- */

.contact {
  width: min(520px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  background: rgba(24, 25, 30, 0.88);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
          backdrop-filter: blur(24px) saturate(1.4);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.contact[open] { animation: pop 0.22s cubic-bezier(.2,.8,.2,1); }
/* the dialog takes focus itself on open (main.js), so no field or button lights up; it needs no ring of its own */
.contact:focus-visible { outline: none; }
.contact::backdrop { background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.contact-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.contact h2 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }

.close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: pointer;
}
.close:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); }
.close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.contact form { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.contact input, .contact textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, background-color 0.2s;
}

.contact ::placeholder { color: var(--faint); opacity: 1; }
.contact textarea { resize: none; min-height: 132px; }
.contact input:focus, .contact textarea:focus { outline: none; border-color: rgba(10, 132, 255, 0.8); background: rgba(255, 255, 255, 0.08); }
.contact .invalid { border-color: rgba(255, 69, 58, 0.8); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.contact-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 6px; }
.status { margin: 0; color: var(--muted); font-size: 0.875rem; }
.status.error { color: #ff6961; }
.privacy { margin: 10px 0 0; color: var(--faint); font-size: 0.75rem; line-height: 1.4; }

.send {
  padding: 11px 26px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}
.send:hover { background: #2a95ff; }
.send:disabled { opacity: 0.6; cursor: default; }

/* light switch on: a white dialog with light fields; Send stays blue */
:root[data-light] .contact { border-color: rgba(0, 0, 0, 0.08); background: rgba(255, 255, 255, 0.92); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18); }
:root[data-light] .contact::backdrop { background: rgba(0, 0, 0, 0.2); }
:root[data-light] .close, :root[data-light] .contact input, :root[data-light] .contact textarea { background: rgba(0, 0, 0, 0.05); }
:root[data-light] .close:hover { background: rgba(0, 0, 0, 0.09); }
:root[data-light] .contact input:focus, :root[data-light] .contact textarea:focus { background: #fff; }
:root[data-light] .status.error { color: #d70015; } /* the dark theme's red is too pale on white */

/* ---------- Small screens ---------- */

@media (max-width: 520px) {
  .project { grid-template-columns: 64px 1fr; gap: 16px; }
  .icon { width: 64px; height: 64px; }
  .title { font-size: 1.125rem; }
  .row { grid-template-columns: 1fr; }
  .contact { padding: 22px; }
  /* tighter rhythm so the page fits one phone screen and a finger drags the sheet instead of scrolling */
  main { padding-top: 32px; }
  .photo { width: 96px; height: 96px; margin-bottom: 20px; }
  .rule { margin-top: 20px; }
  .project { padding: 16px 12px; }
  .cta { padding-top: 16px; }
  footer { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
