/* Skyline — a living sky backdrop for a modern blog.
   Day: gradient sky, sun, drifting clouds.
   Night: deep gradient, moon, twinkling stars.
   State lives in <html data-sky="day|night">, see static/js/theme.js. */

:root {
  --sky-top: #3f97f6;
  --sky-mid: #7fc2ff;
  --sky-bottom: #eaf6ff;
  --sun-core: #fff3d1;
  --sun-glow: rgba(255, 214, 110, 0.55);
  --cloud: rgba(255, 255, 255, 0.92);
  --cloud-shadow: rgba(90, 130, 170, 0.18);

  --text: #1b2430;
  --muted: #55606e;
  --accent: #1866c4;
  --accent-soft: rgba(24, 102, 196, 0.12);

  --card-bg: rgba(255, 255, 255, 0.6);
  --card-border: rgba(255, 255, 255, 0.75);
  --card-shadow: rgba(40, 70, 110, 0.18);
  --header-bg: rgba(255, 255, 255, 0.38);
  --divider: rgba(30, 40, 55, 0.1);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --radius: 18px;
}

html[data-sky="night"] {
  --sky-top: #04060f;
  --sky-mid: #0b1330;
  --sky-bottom: #1c2c50;
  --moon-core: #f6f2e7;
  --moon-shade: rgba(0, 0, 0, 0.12);
  --moon-glow: rgba(230, 225, 200, 0.35);

  --text: #eef1f8;
  --muted: #a4aec4;
  --accent: #8fc1ff;
  --accent-soft: rgba(143, 193, 255, 0.14);

  --card-bg: rgba(16, 20, 38, 0.55);
  --card-border: rgba(255, 255, 255, 0.1);
  --card-shadow: rgba(0, 0, 0, 0.45);
  --header-bg: rgba(6, 9, 20, 0.45);
  --divider: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  transition: color 0.5s ease;
}

/* ---------- sky backdrop ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--sky-top) 0%,
    var(--sky-mid) 45%,
    var(--sky-bottom) 100%
  );
  transition: background 0.8s ease;
}

/* sun / moon */
.sky .orb {
  position: absolute;
  top: 8%;
  right: 12%;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.sky .sun {
  background: radial-gradient(circle at 35% 35%, var(--sun-core), #ffb648 70%);
  box-shadow: 0 0 90px 30px var(--sun-glow);
  opacity: 1;
}

.sky .moon {
  background: radial-gradient(circle at 35% 35%, var(--moon-core, #f6f2e7), #cfc9b8 75%);
  box-shadow:
    0 0 70px 18px var(--moon-glow, rgba(230, 225, 200, 0.35)),
    -18px -10px 0 -6px var(--moon-shade, rgba(0,0,0,.12)) inset,
    10px 18px 0 -14px var(--moon-shade, rgba(0,0,0,.12)) inset;
  opacity: 0;
  transform: scale(0.85);
}

html[data-sky="night"] .sky .sun { opacity: 0; transform: scale(0.85); }
html[data-sky="night"] .sky .moon { opacity: 1; transform: scale(1); }

/* clouds — pure CSS puff shapes, drifting */
.sky .clouds { position: absolute; inset: 0; transition: opacity 0.8s ease; }
html[data-sky="night"] .sky .clouds { opacity: 0; }

.cloud {
  position: absolute;
  background: var(--cloud);
  border-radius: 100px;
  filter: drop-shadow(0 10px 12px var(--cloud-shadow));
  opacity: 0.9;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: var(--cloud);
  border-radius: 50%;
}
.cloud::before { width: 60%; height: 140%; top: -55%; left: 8%; }
.cloud::after { width: 45%; height: 110%; top: -40%; right: 12%; }

/* higher clouds (smaller top%) sit further away, so they drift slower;
   lower clouds are closer and move noticeably faster (parallax) */
.cloud-3 { width: 200px; height: 54px; top: 8%;  left: -260px; animation: drift 130s linear infinite; animation-delay: -60s; }
.cloud-1 { width: 160px; height: 46px; top: 16%; left: -220px; animation: drift 100s linear infinite; }
.cloud-2 { width: 110px; height: 34px; top: 26%; left: -180px; animation: drift 75s linear infinite; animation-delay: -20s; opacity: 0.75; }
.cloud-4 { width: 90px;  height: 28px; top: 36%; left: -150px; animation: drift 50s linear infinite; animation-delay: -10s; opacity: 0.65; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 300px)); }
}

/* stars — individually-placed dots, each twinkling on its own cycle */
.sky .stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1s ease;
}
html[data-sky="night"] .sky .stars { opacity: 1; }

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.65);
  opacity: 0.25;
  animation-name: twinkle;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1); }
}

/* ---------- layout ---------- */

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.25rem 6rem;
}
.wrap.wrap-wide { max-width: 1040px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 2.5rem;
  align-items: start;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  margin: 0 0 3rem;
  background: var(--header-bg);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--card-border);
}

.site-header .titles h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
.site-header .titles h1 a { color: inherit; text-decoration: none; }
.site-header .titles p.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.sky-toggle {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.5s ease;
}
.sky-toggle:hover { transform: scale(1.08); }
.sky-toggle svg { width: 20px; height: 20px; }
.sky-toggle .icon-moon { display: none; }
html[data-sky="night"] .sky-toggle .icon-sun { display: none; }
html[data-sky="night"] .sky-toggle .icon-moon { display: block; }

main { padding-top: 0.5rem; }

/* post cards */
.post-summary {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px -18px var(--card-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.5s ease, border-color 0.5s ease;
}
.post-summary:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 34px -16px var(--card-shadow);
}
.post-summary h2 { margin: 0 0 0.3rem; font-size: 1.35rem; letter-spacing: -0.01em; }
.post-summary h2 a { color: var(--text); text-decoration: none; }
.post-summary h2 a:hover { color: var(--accent); }
.post-date { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.8rem; }
.post-excerpt { color: var(--text); opacity: 0.9; }
.read-more {
  display: inline-block;
  margin-top: 0.9rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.read-more:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 3rem 1rem;
}

/* archive sidebar */
.archive {
  position: sticky;
  top: 6.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem 1.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px -18px var(--card-shadow);
  transition: background 0.5s ease, border-color 0.5s ease;
  max-height: calc(100vh - 8.5rem);
  overflow-y: auto;
}
.archive-title {
  margin: 0 0 0.9rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.archive-year { margin-bottom: 1.2rem; }
.archive-year:last-child { margin-bottom: 0; }
.archive-year h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--text);
}
.archive-year ul { list-style: none; margin: 0; padding: 0; }
.archive-year li { margin-bottom: 0.5rem; }
.archive-year a {
  display: flex;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  opacity: 0.85;
  line-height: 1.4;
}
.archive-year a:hover { color: var(--accent); opacity: 1; }
.archive-date {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .archive { position: static; max-height: none; order: 2; margin-top: 0.5rem; }
}

/* single post */
.post-full {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem 2.25rem 2.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px -18px var(--card-shadow);
}
.post-full h1 { margin: 0 0 0.3rem; font-size: 2rem; letter-spacing: -0.01em; }
.post-content { margin-top: 1.5rem; }
.post-content img { max-width: 100%; height: auto; border-radius: 12px; }
.post-content pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 10px;
}
html[data-sky="night"] .post-content pre { background: rgba(255, 255, 255, 0.08); }
.post-content blockquote {
  border-left: 3px solid var(--accent);
  margin-left: 0;
  padding-left: 1rem;
  color: var(--muted);
}
.post-content a { color: var(--accent); }

.back-link {
  display: inline-block;
  margin-top: 1.75rem;
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .cloud, .star, .sky .orb, body, .sky, .clouds, .post-summary {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 520px) {
  .site-header { padding: 1rem; }
  .post-summary { padding: 1.25rem 1.4rem; }
  .post-full { padding: 1.5rem 1.5rem 2rem; }
  .sky .orb { width: 80px; height: 80px; top: 6%; right: 8%; }
}
