/* css/site.css — timbeach.com design tokens + base */

:root {
  /* === Light mode (default) === */
  --bg:           #fbfaf6;
  --bg-elev:      #f3f0e8;
  --fg:           #111111;
  --fg-muted:     #555555;
  --fg-faint:     #888888;
  --divider:      #d8d4cc;
  --rule-bold:    #111111;
  --link:         #111111;
  --link-hover:   #000000;
  --selection:    #d8d4cc;

  /* Star palette — dimmer ink dots in light mode (stars on paper, more like
     pencil marks against cream than literal stars). */
  --star-color: #6a6760;
  --star-glow:  rgba(0, 0, 0, 0.08);

  /* Typography: Charter family (low-DPI laser-printer descendant — chunky and
     newspaper-y) with sturdy fallbacks. Charis SIL is the free Google Fonts
     equivalent of Bitstream Charter; "Iowan Old Style" is the macOS
     near-equivalent; Georgia is the universal final fallback. */
  --font-serif: "Charis SIL", Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Sizing */
  --page-width:    860px;
  --content-width: 720px;
}

[data-theme="dark"] {
  --bg:        #0e0e0e;
  --bg-elev:   #1a1a18;
  --fg:        #e6e3da;
  --fg-muted:  #9a958a;
  --fg-faint:  #6e6a60;
  --divider:   #2a2a28;
  --rule-bold: #e6e3da;
  --link:      #e6e3da;
  --link-hover: #ffffff;
  --selection: #3a3a36;

  /* Stars become bright warm-white with a glow against the night sky. */
  --star-color: #f6f1e0;
  --star-glow:  rgba(246, 241, 224, 0.45);
}

/* Default = light mode regardless of OS preference. Dark mode is opt-in
   via the sun/moon toggle (persisted to localStorage). */

/* === Reset === */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--selection); }

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid var(--divider);
  transition: color 0.15s, border-color 0.15s;
}
a:hover { color: var(--link-hover); border-bottom-color: var(--fg); }

/* === Page container === */

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* === Masthead === */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 3px solid var(--rule-bold);
  padding-bottom: 12px;
  margin-bottom: 32px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 0;
  border: none;
}
.brand:hover { border: none; }

.nav {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.nav a { margin-left: 16px; border: none; color: var(--fg-muted); }
.nav a:hover { color: var(--fg); }
.nav a.active { color: var(--fg); }

.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  margin-left: 16px;
  padding: 4px;
  color: var(--fg-muted);
  font-size: 16px;
  line-height: 1;
}
.theme-toggle:hover { color: var(--fg); }

/* === Type scale === */

h1, h2, h3, h4 { font-family: var(--font-serif); margin: 0; }

.meta {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 6px;
}

/* === Footer === */

.site-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  text-align: center;
}
.site-footer a { color: var(--fg-faint); border: none; }
.site-footer a:hover { color: var(--fg); }

/* === Homepage === */

.lead {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 28px;
  max-width: var(--content-width);
}
.lead .headline {
  font-size: clamp(28px, 4vw, 32px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.lead .headline a { color: var(--fg); border: none; }
.lead .headline a:hover { color: var(--link-hover); }
.lead .lede {
  font-size: 17px;
  line-height: 1.5;
  color: var(--fg-muted);
  margin: 0;
}

.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 28px;
}
.cards-row .card-headline {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 6px;
}
.cards-row .card-headline a { color: var(--fg); border: none; }
.cards-row .card-headline a:hover { color: var(--link-hover); }
.cards-row .card-summary {
  font-size: 13px;
  line-height: 1.4;
  color: var(--fg-muted);
  margin: 0;
}

.more h2 {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 12px;
}
.more ul { list-style: none; padding: 0; margin: 0; }
.more li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--divider);
  align-items: baseline;
}
.more li time {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.04em;
}
.more li a {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--fg);
  border: none;
}
.more li a:hover { color: var(--link-hover); }

/* === Article reading view === */

.back-link {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border: none;
  display: inline-block;
  margin-bottom: 24px;
}
.back-link:hover { color: var(--fg); border: none; }

.article {
  max-width: var(--content-width);
}
.article-header { margin-bottom: 32px; }
.article-header .meta { margin-bottom: 8px; }
.article-header h1 {
  font-size: clamp(28px, 4vw, 32px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.read-aloud,
.share-link {
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.read-aloud:hover,
.share-link:hover {
  color: var(--fg);
  border-color: var(--fg);
}
.share-link.copied {
  color: var(--fg);
  border-color: var(--fg);
}

.article-body { font-size: 17px; line-height: 1.65; }
.article-body p { margin: 0 0 1.1em; }
.article-body h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  margin: 1.6em 0 0.5em;
}
.article-body h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  margin: 1.4em 0 0.5em;
}
.article-body h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 1.2em 0 0.4em;
}
.article-body ul, .article-body ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.article-body li { margin-bottom: 0.4em; }

.article-body a { color: var(--fg); border-bottom: 1px solid var(--fg-muted); }
.article-body a:hover { border-bottom-color: var(--fg); }

.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.2em 0;
  cursor: zoom-in;
}

.article-body hr {
  border: 0;
  height: 0;
  border-top: 2px solid var(--rule-bold);
  margin: 2.4em 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-elev);
  padding: 1px 4px;
  border-radius: 3px;
}
.article-body pre {
  font-family: var(--font-mono);
  background: var(--bg-elev);
  padding: 16px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
  margin: 1.2em 0;
  border-radius: 4px;
}
.article-body pre code { background: none; padding: 0; font-size: inherit; }

.article-body blockquote {
  border-left: 3px solid var(--divider);
  padding-left: 16px;
  margin: 1.2em 0;
  color: var(--fg-muted);
  font-style: italic;
}

.article-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 14px;
}
.article-body th, .article-body td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider);
}
.article-body th {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* === TTS read-aloud bar === */

.tts-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: var(--bg);
  border-top: 1px solid var(--divider);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-sans);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .tts-bar { box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .tts-bar { box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4); }
}
.tts-bar.visible { transform: translateY(0); }

.tts-bar-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tts-progress-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--divider);
}
.tts-progress-fill {
  height: 100%;
  background: var(--fg-muted);
  width: 0%;
  transition: width 0.3s ease;
}

.tts-transport { display: flex; gap: 6px; flex-shrink: 0; }
.tts-btn {
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--fg);
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tts-btn:hover { border-color: var(--fg); }
.tts-btn svg { width: 14px; height: 14px; }

.tts-status { flex: 1; min-width: 0; font-size: 12px; }
.tts-status-label {
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  margin-right: 6px;
}
.tts-status-text {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 60%;
  vertical-align: bottom;
}

.tts-speed { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.tts-speed-label { color: var(--fg-faint); }
.tts-speed-slider { width: 80px; accent-color: var(--fg); }

.tts-close {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
}
.tts-close:hover { color: var(--fg); }

.article-body.tts-active > * { opacity: 0.45; transition: opacity 0.3s; }
.article-body.tts-active .tts-reading { opacity: 1; }

body.tts-open .page { padding-bottom: 88px; }

/* === Music page === */

.music-page {
  max-width: 480px;
  margin: 48px auto 0;
  text-align: center;
}
.music-cover {
  /* reset button defaults */
  appearance: none;
  font: inherit;
  padding: 0;
  /* layout */
  width: 280px;
  height: 280px;
  margin: 0 auto 32px;
  background: var(--bg-elev);
  border: 1px solid var(--divider);
  display: block;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.music-cover:hover { transform: scale(1.02); }
.music-cover:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }
.music-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.music-cover-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.6);
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.music-cover:hover .music-cover-play { opacity: 1; }

/* === Lightbox (album-art promo video) === */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lightbox.open { display: flex; opacity: 1; }
.lightbox-video,
.lightbox-image {
  max-height: 90vh;
  max-width: 90vw;
  cursor: default;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  background: #000;
}
/* Lightboxed article images render at natural size; the zoom-in cursor hint
   on the inline thumbnail doesn't apply to the enlarged view. */
.lightbox-image { margin: 0; }
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.9);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { color: #fff; border-color: #fff; }
.music-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 0 0 6px;
}
.music-artist {
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 14px;
}
.music-status {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 32px;
}
.music-link[data-link-live="false"] {
  color: var(--fg-faint);
  border: none;
  pointer-events: none;
  cursor: default;
  font-family: var(--font-sans);
  font-size: 13px;
}
.music-link[data-link-live="false"]::after {
  content: " (soon)";
  font-style: italic;
}
.music-link[data-link-live="true"] {
  color: var(--fg);
  border-bottom: 1px solid var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 13px;
}
.music-streaming {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg-muted);
  margin: 0 0 18px;
}
.music-streaming a {
  color: var(--fg);
  border-bottom: 1px solid var(--fg-muted);
  text-decoration: none;
  padding-bottom: 1px;
  transition: border-color 0.15s ease;
}
.music-streaming a:hover { border-bottom-color: var(--fg); }
.music-streaming .sep {
  margin: 0 0.55em;
  color: var(--fg-faint);
}

/* === Starfield (only on /about) === */

.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.star {
  position: absolute;
  border-radius: 50%;
  background: var(--star-color);
  opacity: 0.85;
  box-shadow: 0 0 3px var(--star-glow);
  animation: twinkle 4s infinite ease-in-out;
}
.star.bright {
  opacity: 1;
  box-shadow: 0 0 6px var(--star-glow);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

.sky-info {
  position: fixed;
  bottom: 16px;
  left: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-faint);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border: 1px solid var(--divider);
  padding: 6px 10px;
  border-radius: 4px;
  line-height: 1.6;
  z-index: 1000;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.sky-info:hover { color: var(--fg-muted); background: var(--bg); }

.sky-info-tooltip {
  position: absolute;
  left: 100%;
  bottom: 0;
  margin-left: 12px;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--divider);
  padding: 12px 16px;
  border-radius: 4px;
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-muted);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 2;
}
.sky-info:hover .sky-info-tooltip {
  opacity: 1;
  transform: translateX(0);
}
.sky-info-tooltip h4 {
  margin: 0 0 6px;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sky-info-tooltip p { margin: 6px 0; color: var(--fg-muted); }
.sky-info-tooltip .hint { margin-top: 10px; color: var(--fg-faint); font-style: italic; }

/* Touch devices can't hover, so the tooltip is unreachable there.
   Tap-to-toggle (the click handler) still works. */
@media (hover: none) {
  .sky-info-tooltip { display: none; }
}

/* Stars-only view: click the sky-info widget to fade out everything
   except the starfield + the widget itself. Click again to return. */
body.stars-view .masthead,
body.stars-view #app,
body.stars-view .site-footer {
  opacity: 0;
  pointer-events: none;
}
.masthead, #app, .site-footer { transition: opacity 0.5s ease; }

/* === About page === */

/* The about-page section gets an opaque pad so prose stays legible
   against the starfield. Stars are still visible in the gutters
   around it. */
.about-page {
  max-width: var(--content-width);
  background: var(--bg);
  padding: 24px 28px;
  border-radius: 4px;
}
.about-page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
.about-page p {
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 1em;
}
.about-page .links {
  margin-top: 24px;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.about-page .links a { color: var(--fg-muted); border: none; margin-right: 16px; }
.about-page .links a:hover { color: var(--fg); }

/* === Responsive === */

@media (max-width: 760px) {
  .page { padding: 24px 16px 48px; }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .nav { font-size: 10px; }
  .nav a { margin-left: 0; margin-right: 12px; }
  .nav a:last-of-type { margin-right: 0; }

  .lead .headline { font-size: 26px; }

  .cards-row {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .more li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .more li time { font-size: 10px; }

  .article-header h1 { font-size: 26px; }

  .tts-bar-inner {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 8px;
  }
  .tts-status { order: 99; flex-basis: 100%; }
  .tts-speed { display: none; } /* drop slider on mobile to save space */

  .music-cover { width: 220px; height: 220px; }
  .music-title { font-size: 26px; }
}
