/* Stardust Notes — shared styles.
   One quiet column over a live night sky; moon-phase stamps date each essay. */
:root {
  --bg: #0a0d22;
  --surface: #141a3a;
  --veil: rgba(20, 26, 58, 0.62);
  --ink: #e9e6f5;
  --ink-soft: #a9a8c8;
  --moon: #f2dcaa;
  --line: rgba(233, 230, 245, 0.14);
  --danger: #f0a3a3;
  --ok: #a8e0c2;
  --ok-line: rgba(168, 224, 194, 0.4);
  --field: rgba(10, 13, 34, 0.6);
  --accent-line: rgba(242, 220, 170, 0.4);
  --card-shadow: rgba(0, 0, 0, 0.35);
  --mark: rgba(242, 220, 170, 0.28);
  --send-bg: #f2dcaa;
  --send-ink: #0a0d22;
  --send-glow: rgba(242, 220, 170, 0.45);
  --backdrop: rgba(5, 7, 20, 0.7);
  --moon-shade: #141a3a;
  --moon-lit: #f2dcaa;
  --thumb-bg: #141a3a;
  --f-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --f-body: "Karla", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
/* Daytime: soft sky, navy ink, the moon's gold deepened to amber so links stay readable. */
:root[data-theme="light"] {
  --bg: #b5d9f5;
  --surface: #f4f9fe;
  --veil: rgba(255, 255, 255, 0.62);
  --ink: #1b2848;
  --ink-soft: #455379;
  --moon: #6e430a;
  --line: rgba(27, 40, 72, 0.16);
  --danger: #a42b2b;
  --ok: #1d6b45;
  --ok-line: rgba(29, 107, 69, 0.45);
  --field: rgba(255, 255, 255, 0.72);
  --accent-line: rgba(110, 67, 10, 0.45);
  --card-shadow: rgba(52, 92, 150, 0.25);
  --mark: rgba(244, 196, 80, 0.45);
  --send-bg: #f0b84a;
  --send-ink: #2a1b05;
  --send-glow: rgba(240, 184, 74, 0.55);
  --backdrop: rgba(30, 50, 90, 0.35);
  --moon-shade: #b9c6de;
  --moon-lit: #e9a93a;
  --thumb-bg: #d3e2f2;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 17px; line-height: 1.7;
  min-height: 100vh; overflow-x: hidden;
}
[hidden] { display: none !important; }
img, video, iframe { max-width: 100%; }
a { color: var(--moon); text-underline-offset: 4px; }
:focus-visible { outline: 2px solid var(--moon); outline-offset: 3px; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.aurora {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 40% at 15% 110%, rgba(110, 160, 200, 0.18), transparent 70%),
    radial-gradient(50% 35% at 90% 105%, rgba(190, 150, 210, 0.14), transparent 70%);
}
:root[data-theme="light"] #sky,
:root[data-theme="light"] .aurora { opacity: 0; }

/* Day sky: built by site.js, fades in over the night sky in light mode. */
.daysky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  opacity: 0; visibility: hidden;
  background:
    radial-gradient(60% 40% at 15% 110%, rgba(255, 214, 170, 0.5), transparent 70%),
    radial-gradient(50% 35% at 90% 105%, rgba(255, 190, 210, 0.38), transparent 70%),
    linear-gradient(180deg, #b5d9f5 0%, #d0e7f8 45%, #eaf3fb 75%, #fbefdc 100%);
}
:root[data-theme="light"] .daysky { opacity: 1; visibility: visible; }
.sun {
  position: absolute; top: -14vmin; right: 6%; width: 46vmin; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 249, 220, 0.95) 0 14%, rgba(255, 242, 196, 0.55) 32%, rgba(255, 242, 196, 0) 68%);
}
.cloud {
  position: absolute; top: var(--top); left: 0; width: var(--w); aspect-ratio: 3.4 / 1;
  border-radius: 999px; background: linear-gradient(#fff, #f1f7fd);
  opacity: var(--o); filter: blur(calc(var(--w) * 0.016));
  animation: drift var(--dur) linear var(--delay) infinite; will-change: transform;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 44%; aspect-ratio: 1; left: 16%; bottom: 32%; }
.cloud::after { width: 32%; aspect-ratio: 1; left: 50%; bottom: 34%; }
:root:not([data-theme="light"]) .cloud { animation-play-state: paused; }

.wrap {
  position: relative; z-index: 1;
  max-width: 60rem; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 1.2rem 5rem;
  display: flex; flex-direction: column; gap: 4rem;
}
.narrow { max-width: 44rem; width: 100%; margin-inline: auto; }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: 0.9rem;
}
.brand {
  font-family: var(--f-display); font-style: italic; font-size: 1.5rem; color: var(--ink);
  text-decoration: none; line-height: 1;
}
.nav-links { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--ink-soft); text-decoration: none; letter-spacing: 0.04em; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"] { border-bottom: 1px solid var(--moon); }
.theme-toggle {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin: -0.5rem -0.6rem -0.5rem 0;
  background: none; border: 0; border-radius: 50%; padding: 0; cursor: pointer; color: var(--ink-soft);
  transition: color .2s ease, background-color .2s ease, transform .2s ease;
}
.theme-toggle:hover { color: var(--ink); background-color: var(--line); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { grid-area: 1 / 1; width: 20px; height: 20px; transition: transform .5s ease, opacity .4s ease; }
.theme-toggle .i-moon, :root[data-theme="light"] .theme-toggle .i-sun { opacity: 0; transform: rotate(-70deg) scale(0.5); }
:root[data-theme="light"] .theme-toggle .i-moon { opacity: 1; transform: none; }
.theme-toggle .i-sun { opacity: 1; transform: none; }

/* ---------- type ---------- */
.eyebrow { font-size: 0.75rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--moon); opacity: 0.85; margin: 0; }
h1, h2, h3 { font-family: var(--f-display); font-style: italic; margin: 0; text-wrap: balance; }
h1 { font-weight: 300; font-size: clamp(2.8rem, 9vw, 4.8rem); line-height: 0.98; animation: rise 1.4s ease-out both; }
h2 { font-weight: 400; font-size: clamp(1.9rem, 5.5vw, 2.6rem); line-height: 1.1; }
h3 { font-weight: 400; font-size: 1.55rem; line-height: 1.15; }
.lede { color: var(--ink-soft); margin: 0; max-width: 34rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.link {
  background: none; border: 0; padding: 0.2rem 0; cursor: pointer;
  font: 500 0.9rem var(--f-body); color: var(--moon); letter-spacing: 0.04em; text-decoration: none;
}
.link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- hero (home) ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: clamp(1.2rem, 4vw, 2.6rem); align-items: center; margin-top: 2rem; }
.avatar {
  width: clamp(96px, 20vw, 150px); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  border: 1px solid var(--line); background: radial-gradient(circle at 35% 30%, #2a3270, #141a3a 70%);
  display: grid; place-items: center; box-shadow: 0 0 60px rgba(242, 220, 170, 0.12);
  animation: rise 1.2s ease-out both;
}
:root[data-theme="light"] .avatar { box-shadow: 0 10px 44px rgba(52, 92, 150, 0.3); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar img[src$=".svg"] { object-fit: contain; padding: 15%; box-sizing: border-box; }
.avatar span { font-family: var(--f-display); font-style: italic; font-size: clamp(3rem, 8vw, 4.4rem); color: #f2dcaa; }
.hero-text { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }
.hero-text p { margin: 0; max-width: 36rem; }
.hero-links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
@media (max-width: 560px) { .hero { grid-template-columns: 1fr; } }

/* ---------- search ---------- */
.search { position: relative; max-width: 28rem; width: 100%; }
.search input {
  width: 100%; background: var(--field); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.65rem 1rem 0.65rem 2.5rem; font: 1rem/1.4 var(--f-body);
}
.search input::placeholder { color: var(--ink-soft); }
.search svg { position: absolute; left: 0.95rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-soft); }
.result-note { color: var(--ink-soft); font-size: 0.9rem; margin: 0.8rem 0 0; min-height: 1.5em; }
mark { background: var(--mark); color: var(--ink); border-radius: 2px; padding: 0 1px; }

/* ---------- essay cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); gap: 1.6rem; }
.card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  transition: transform .3s ease, border-color .3s ease, box-shadow .3s ease;
  animation: rise 1s ease-out both;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent-line); box-shadow: 0 10px 40px var(--card-shadow); }
.thumb { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: var(--thumb-bg); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb canvas { width: 100%; height: 100%; display: block; }
.play {
  position: absolute; right: 0.7rem; bottom: 0.7rem;
  display: flex; align-items: center; gap: 0.35rem;
  background: rgba(10, 13, 34, 0.75); color: #e9e6f5; border-radius: 999px; /* fixed light ink: the pill stays dark in both themes */
  padding: 0.2rem 0.65rem 0.2rem 0.5rem; font-size: 0.75rem; letter-spacing: 0.06em;
}
.card-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.card-body p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

.meta {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 0.78rem; letter-spacing: 0.08em; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.meta svg { flex: none; }
.moon-disc { fill: var(--moon-shade); stroke: var(--line); }
.moon-lit { fill: var(--moon-lit); }

/* ---------- projects ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1.2rem; }
.project {
  background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column;
}
.project .card-body { gap: 0.6rem; }
.pill {
  align-self: flex-start; font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft);
}
.pill[data-status="Live"] { color: var(--ok); border-color: var(--ok-line); }
.pill[data-status="Building"] { color: var(--moon); border-color: var(--accent-line); }

/* ---------- essay page ---------- */
article.essay { display: flex; flex-direction: column; gap: 1.4rem; }
.essay-hero { border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.prose {
  background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 6px;
  padding: clamp(1.4rem, 5vw, 2.4rem);
  display: flex; flex-direction: column; gap: 1.1rem;
}
.prose p { margin: 0; white-space: pre-line; }
.prose h3 { margin-top: 0.8rem; }
.prose figure { margin: 0.4rem 0; display: flex; flex-direction: column; gap: 0.4rem; }
.prose figure img { border-radius: 4px; display: block; width: 100%; height: auto; }
.prose figcaption { color: var(--ink-soft); font-size: 0.85rem; font-style: italic; }
.video { position: relative; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video video { object-fit: contain; } /* tall phone videos get bars instead of being cropped */
figure.video-fig { margin: 0.4rem 0; display: flex; flex-direction: column; gap: 0.4rem; }
.prose .video { margin: 0.4rem 0; }

/* ---------- formatted text (written in the editor) ---------- */
.rich { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.rich p, .rich ul, .rich ol, .rich blockquote, .rich h3 { margin: 0; }
.rich p { white-space: normal; overflow-wrap: anywhere; }
.rich h3 { margin-top: 0.8rem; }
.rich ul, .rich ol { padding-left: 1.5rem; display: flex; flex-direction: column; gap: 0.35rem; }
.rich ul ul, .rich ol ol, .rich ul ol, .rich ol ul { margin-top: 0.35rem; }
.rich li { overflow-wrap: anywhere; }
.rich blockquote {
  border-left: 2px solid var(--accent-line); padding: 0.1rem 0 0.1rem 1.1rem; color: var(--ink-soft);
  font-style: italic; display: flex; flex-direction: column; gap: 0.7rem;
}
.rich a { color: var(--moon); }
.rich u { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.hero-text .rich { gap: 0.8rem; max-width: 36rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.92rem; }
.pager a { max-width: 48%; }

/* ---------- reactions ---------- */
.reactions { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; }
.react-row { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; }
.react {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem; min-width: 4.4rem;
  padding: 0.4rem 0.95rem 0.4rem 0.6rem; border-radius: 999px; cursor: pointer;
  background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line); color: var(--ink-soft);
  font: 600 0.95rem var(--f-body); font-variant-numeric: tabular-nums;
  transition: transform .25s ease, border-color .25s ease, box-shadow .3s ease, color .25s ease;
}
.react img { width: 38px; height: 38px; display: block; opacity: 0.8; filter: saturate(0.75); transition: transform .3s ease, opacity .25s ease, filter .25s ease; }
.react:hover { transform: translateY(-2px); border-color: var(--accent-line); color: var(--ink); }
.react:hover img { transform: scale(1.12) rotate(-5deg); opacity: 1; filter: none; }
.react.on { border-color: var(--moon); color: var(--ink); box-shadow: 0 0 24px var(--send-glow); }
.react.on img { opacity: 1; filter: none; }
.react .count:empty { display: none; }
.react.pop img { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.5) rotate(-9deg); } 70% { transform: scale(0.94) rotate(3deg); } 100% { transform: scale(1); } }
.react-status, #react-status { min-height: 1.2em; margin: 0; }
@media (max-width: 520px) {
  .react-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.45rem; width: 100%; }
  .react { flex-direction: column; gap: 0; min-width: 0; padding: 0.5rem 0.2rem 0.4rem; border-radius: 16px; }
  .react .count { font-size: 0.82rem; line-height: 1.2; min-height: 1.2em; display: block; }
  .react .count:empty { display: block; }
}

/* ---------- comments ---------- */
.comments {
  background: var(--veil); border: 1px solid var(--line); border-radius: 6px;
  padding: clamp(1.2rem, 4vw, 2rem); display: flex; flex-direction: column; gap: 1rem;
}
.thread { display: flex; flex-direction: column; gap: 0.9rem; }
.comment { display: flex; flex-direction: column; gap: 0.15rem; }
.comment .who { font-size: 0.82rem; color: var(--ink-soft); display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: baseline; }
.comment .who strong { color: var(--ink); font-weight: 600; }
.comment .text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.del { background: none; border: 0; padding: 0; cursor: pointer; font: 0.78rem var(--f-body); color: var(--ink-soft); }
.del:hover { color: var(--danger); }
.empty { color: var(--ink-soft); font-size: 0.92rem; margin: 0; font-style: italic; }
.cform { display: flex; flex-direction: column; gap: 0.6rem; }
.gate { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; font-size: 0.92rem; color: var(--ink-soft); }
textarea, input[type="text"], input[type="password"] {
  width: 100%; background: var(--field); color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 0.7rem 0.8rem; font: 1rem/1.5 var(--f-body);
}
textarea { min-height: 5.5rem; resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--ink-soft); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.send {
  background: var(--send-bg); color: var(--send-ink); border: 0; border-radius: 999px; padding: 0.5rem 1.3rem;
  font: 600 0.9rem var(--f-body); cursor: pointer; transition: box-shadow .3s, transform .2s;
}
.send:hover { box-shadow: 0 0 22px var(--send-glow); transform: translateY(-1px); }
.send:disabled { opacity: .5; cursor: default; box-shadow: none; transform: none; }
.status { font-size: 0.82rem; color: var(--ink-soft); }
.status.err { color: var(--danger); }
.account { display: flex; gap: 0.8rem; align-items: center; color: var(--ink-soft); font-size: 0.88rem; flex-wrap: wrap; }
.account strong { color: var(--ink); font-weight: 600; }

dialog {
  width: min(24rem, calc(100vw - 32px)); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 1.6rem;
}
dialog::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog h3 { font-size: 1.9rem; margin-bottom: 0.2rem; }
dialog form { display: flex; flex-direction: column; gap: 0.9rem; }
dialog label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-soft); }
.hint { font-size: 0.78rem; color: var(--ink-soft); }
.tabs { display: flex; gap: 1.2rem; border-bottom: 1px solid var(--line); margin-bottom: 0.4rem; }
.tabs button {
  background: none; border: 0; padding: 0.4rem 0; cursor: pointer; margin-bottom: -1px;
  font: 500 0.9rem var(--f-body); color: var(--ink-soft); border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--moon); }

footer { color: var(--ink-soft); font-size: 0.85rem; text-align: center; }

/* ---------- theme switch ---------- */
/* Added by theme.js for a moment while the theme changes, so colours and the two skies cross-fade together. */
html.theme-fading, html.theme-fading *, html.theme-fading *::before, html.theme-fading *::after {
  transition: background-color .7s ease, color .7s ease, border-color .7s ease, box-shadow .7s ease,
    fill .7s ease, stroke .7s ease, opacity .7s ease, visibility .7s ease, transform .5s ease !important;
}

@keyframes rise { from { opacity: .001; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes drift { from { transform: translate3d(-100%, 0, 0); } to { transform: translate3d(100vw, 0, 0); } }
@media (prefers-reduced-motion: reduce) {
  h1, .avatar, .card { animation: none; }
  .cloud { animation: none; transform: translate3d(var(--x), 0, 0); }
  .card, .send, .react, .react img { transition: none; }
  .react.pop img { animation: none; }
  .card:hover { transform: none; }
  html { scroll-behavior: auto; }
}
