:root {
  --blue: #3ab4e8;
  --blue-deep: #1b8fc7;
  --ink: #4a5560;
  --ink-soft: #8793a0;
  --edge: #d3dbe2;
  --white: #fff;
  --dock-h: 150px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 30%, #ffffff 0%, #f1f4f7 55%, #dfe5ea 100%);
  background-attachment: fixed;
  padding-bottom: calc(var(--dock-h) + 24px);
}

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

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

/* ---------- Home: channel grid ---------- */

.menu { max-width: 1040px; margin: 0 auto; padding: 36px 24px 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  border-radius: 20px;
  border: 3px solid var(--edge);
  background: linear-gradient(180deg, #ffffff 0%, #f4f7f9 55%, #e6ecf0 100%);
  box-shadow: inset 0 2px 0 #fff, 0 3px 8px rgba(80, 100, 120, .12);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  overflow: hidden;
}

/* gloss highlight on the top half */
.tile::before {
  content: ""; position: absolute; inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.1));
  pointer-events: none;
}

a.tile:hover, a.tile:focus-visible {
  transform: scale(1.06);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(58, 180, 232, .35), 0 0 22px 4px rgba(58, 180, 232, .55);
  outline: none;
  z-index: 2;
}

.tile.empty { background: linear-gradient(180deg, #f3f6f8, #e8edf1); box-shadow: inset 0 2px 6px rgba(80,100,120,.1); }
.tile.empty::before { display: none; }

.tile-art { color: var(--blue-deep); display: grid; place-items: center; }
.icon { width: 54px; height: 54px; }
.tile-label { font-weight: 800; font-size: 1.05rem; letter-spacing: .01em; }

/* ---------- Channel pages ---------- */

.panel-wrap { max-width: 820px; margin: 0 auto; padding: 32px 20px 0; }

.channel-head { text-align: center; margin-bottom: 20px; }
.channel-head h1 { margin: 6px 0 2px; font-size: 2.2rem; font-weight: 800; }
.channel-head p { margin: 0; color: var(--ink-soft); }

.back {
  display: inline-block; padding: 6px 16px; border-radius: 999px;
  border: 2px solid var(--edge); background: linear-gradient(#fff, #eef2f5);
  font-weight: 800; font-size: .85rem; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.back:hover { border-color: var(--blue); box-shadow: 0 0 12px rgba(58,180,232,.5); }

.panel {
  background: linear-gradient(180deg, #fff, #f7f9fb);
  border: 3px solid var(--edge);
  border-radius: 24px;
  box-shadow: 0 4px 14px rgba(80,100,120,.12);
  padding: 20px;
}

.rows { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: grid; gap: 2px; padding: 14px 18px; border-radius: 14px;
  border: 2px solid var(--edge); background: #fff;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.row:hover { transform: scale(1.015); border-color: var(--blue); box-shadow: 0 0 14px rgba(58,180,232,.5); }
.row time { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.row strong { font-size: 1.15rem; }
.row span { color: var(--ink-soft); }

.empty-note { text-align: center; color: var(--ink-soft); padding: 28px 0; margin: 0; }

.button {
  display: block; width: fit-content; margin: 0 auto 16px; padding: 10px 28px;
  border-radius: 999px; font-weight: 800; color: #fff;
  background: linear-gradient(var(--blue), var(--blue-deep));
  box-shadow: 0 2px 8px rgba(27,143,199,.4);
}

.post { padding: 8px 10px 4px; line-height: 1.7; font-size: 1.05rem; }
.post time { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.post h2 { margin: 2px 0 14px; font-size: 1.8rem; }
.post img { max-width: 100%; border-radius: 12px; }
.post a { color: var(--blue-deep); text-decoration: underline; }
.post blockquote { margin: 1em 0; padding-left: 1em; border-left: 4px solid var(--edge); color: var(--ink-soft); }
.post pre { overflow-x: auto; padding: 12px; background: #eef2f5; border-radius: 10px; }

/* ---------- Bottom dock ---------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--dock-h);
  overflow: hidden; pointer-events: none; z-index: 10;
}
.dock > * { pointer-events: auto; }

.dock-curve {
  position: absolute; left: -15%; right: -15%; top: 38px; height: 400px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #f1f4f7 100%);
  border: 4px solid var(--edge);
  box-shadow: 0 -4px 14px rgba(80,100,120,.15);
  pointer-events: none;
}

.orb {
  position: absolute; bottom: 24px; width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #fff 0%, #e8eef2 100%);
  border: 4px solid var(--edge);
  box-shadow: inset 0 3px 0 #fff, 0 3px 8px rgba(80,100,120,.2);
  font-weight: 800; font-size: 1.5rem; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.orb:hover, .orb:focus-visible {
  border-color: var(--blue); outline: none; transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(58,180,232,.35), 0 0 20px 4px rgba(58,180,232,.55);
}
.orb-left { left: max(24px, 6vw); }
.orb-right { right: max(24px, 6vw); }
.orb .icon { width: 42px; height: 42px; color: var(--ink-soft); }

.clock {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  text-align: center; color: var(--ink-soft);
}
.time { font-size: 3.2rem; font-weight: 800; line-height: 1; letter-spacing: .04em; }
.time .colon { animation: blink 2s steps(1) infinite; }
.date { margin-top: 4px; font-weight: 600; font-size: 1rem; }

@keyframes blink { 50% { opacity: .15; } }

@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tile.empty:nth-child(n+9) { display: none; }
  .time { font-size: 2.2rem; }
  .orb { width: 68px; height: 68px; font-size: 1.15rem; bottom: 30px; }
  .orb .icon { width: 32px; height: 32px; }
  :root { --dock-h: 130px; }
}

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

/* ---------- Per-channel tints + animated background canvas ---------- */

body {
  --bg-a: #f1f4f7;
  --bg-b: #dfe5ea;
  background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, var(--bg-a) 55%, var(--bg-b) 100%);
  background-attachment: fixed;
}
body[data-theme="writing"]    { --bg-a: #fbf7ec; --bg-b: #eadfc2; }
body[data-theme="newsletter"] { --bg-a: #eef6fc; --bg-b: #cfe6f5; }
body[data-theme="projects"]   { --bg-a: #eff8f1; --bg-b: #cfe8d6; }
body[data-theme="photos"]     { --bg-a: #f6f0fa; --bg-b: #ded0ec; }
body[data-theme="about"]      { --bg-a: #fdf3ee; --bg-b: #f2d9cb; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.menu, .panel-wrap { position: relative; z-index: 1; }

/* ---------- Sound toggle ---------- */

.sound-toggle {
  position: fixed; top: 14px; right: 14px; z-index: 20;
  width: 42px; height: 42px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-soft);
  border: 3px solid var(--edge); background: linear-gradient(#fff, #e8eef2);
  transition: border-color .15s, box-shadow .15s;
}
.sound-toggle:hover, .sound-toggle:focus-visible {
  border-color: var(--blue); outline: none; box-shadow: 0 0 14px rgba(58,180,232,.55);
}
.sound-toggle .icon { width: 22px; height: 22px; }
.sound-toggle .mute { display: none; }
.sound-toggle.muted .waves { display: none; }
.sound-toggle.muted .mute { display: inline; }

/* ---------- Motion: page entrance + view transitions ---------- */

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .18s ease-in both vt-out; }
::view-transition-new(root) { animation: .28s ease-out both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: scale(1.03); } }
@keyframes vt-in { from { opacity: 0; transform: scale(.97); } }

.tile { animation: pop .45s cubic-bezier(.2, 1.3, .4, 1) both; animation-delay: calc(var(--i, 6) * 55ms); }
.panel { animation: pop .4s cubic-bezier(.2, 1.2, .4, 1) both; }
.channel-head { animation: drop .4s ease-out both; }
@keyframes pop { from { opacity: 0; transform: scale(.85) translateY(10px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-12px); } }

/* ---------- About: Mii-style avatar ---------- */

.about { display: flex; gap: 24px; align-items: center; }
.about .post { flex: 1; }
.mii-card { margin: 0; text-align: center; flex: none; }
.mii { display: block; margin: 0 auto; width: 170px; height: auto; overflow: visible; }
.mii .skin  { fill: #f6d2ae; }
.mii .hair  { fill: #35261d; }
.mii .shirt { fill: var(--blue); }
.mii .shadow { fill: rgba(80, 100, 120, .18); }
.mii .cheek { fill: rgba(255, 140, 130, .35); }
.mii .eyes ellipse { fill: #2a2a2e; transform-box: fill-box; transform-origin: center; animation: eyeblink 4.5s infinite; }
.mii .brows, .mii .nose, .mii .mouth { fill: none; stroke: #4a3a30; stroke-width: 3.5; stroke-linecap: round; }
.mii .nose { stroke: #c9976a; stroke-width: 3; }
.mii-bob { animation: bob 3s ease-in-out infinite; }
.mii-card figcaption {
  display: inline-block; margin-top: 6px; padding: 4px 18px; border-radius: 999px;
  border: 2px solid var(--edge); background: linear-gradient(#fff, #eef2f5);
  font-weight: 800; color: var(--ink);
}
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes eyeblink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

/* ---------- Richer post typography (imported newsletter HTML) ---------- */

.post h1 { font-size: 1.5rem; margin: 1.2em 0 .4em; }
.post h3 { font-size: 1.15rem; }
.post figure { margin: 1em 0; }
.post figcaption { font-size: .85rem; color: var(--ink-soft); text-align: center; }
.post img { height: auto; }
.post hr { border: 0; border-top: 3px solid var(--edge); margin: 1.5em 0; }

@media (max-width: 760px) {
  .about { flex-direction: column; }
  .sound-toggle { top: 10px; right: 10px; }
}

/* ---------- Newsletter blurb + embedded videos ---------- */

.blurb { margin: 0 0 18px; text-align: center; line-height: 1.6; color: var(--ink-soft); }
.blurb a { color: var(--blue-deep); font-weight: 800; text-decoration: underline; }

.video { position: relative; aspect-ratio: 16 / 9; margin: 1.2em 0; border-radius: 14px; overflow: hidden;
  border: 3px solid var(--edge); background: #000; box-shadow: 0 3px 10px rgba(80,100,120,.18); }
.video.short { aspect-ratio: 9 / 16; max-width: 320px; margin-left: auto; margin-right: auto; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Links page + home button ---------- */

body[data-theme="links"] { --bg-a: #eef9f8; --bg-b: #cdeae6; }
.row.soon { opacity: .6; cursor: default; }
.row.soon:hover { transform: none; border-color: var(--edge); box-shadow: none; }
.orb-left .icon { width: 46px; height: 46px; color: var(--ink); }
