/* ═══════════════════════════════════════════════
   daytone — style.css
   ═══════════════════════════════════════════════ */

/* ── Reset & Custom Properties ── */

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

:root {
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Inter", system-ui, sans-serif;

  --ink: 0, 0, 0;
  --text: rgba(var(--ink), 1);
  --text-muted: rgba(var(--ink), 0.75);
  --text-faint: rgba(var(--ink), 0.5);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Base ── */

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  position: relative;
  background: #1a3a2a;
  --bg-h: 160;
  --bg-s: 20;
  --bg-l: 15;
}

/* ── Background: animated gradient ── */

body::before {
  content: "";
  position: fixed;
  inset: -80%;
  width: 260%;
  height: 260%;
  background:
    radial-gradient(
      ellipse at 20% 10%,
      hsla(
        calc(var(--bg-h) + 30),
        calc((var(--bg-s) + 25) * 1%),
        calc((var(--bg-l) + 14) * 1%),
        0.85
      ),
      transparent 40%
    ),
    radial-gradient(
      ellipse at 80% 90%,
      hsla(
        calc(var(--bg-h) - 25),
        calc((var(--bg-s) + 20) * 1%),
        calc((var(--bg-l) + 10) * 1%),
        0.75
      ),
      transparent 40%
    ),
    radial-gradient(
      ellipse at 60% 40%,
      hsla(
        calc(var(--bg-h) + 50),
        calc((var(--bg-s) + 12) * 1%),
        calc((var(--bg-l) + 6) * 1%),
        0.6
      ),
      transparent 50%
    );
  animation: drift var(--drift-duration, 12s) ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(5%, -6%) rotate(2deg);
  }
  50% {
    transform: translate(-4%, 5%) rotate(-1.5deg);
  }
  75% {
    transform: translate(-6%, -3%) rotate(1.5deg);
  }
}

.wrapper {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 440px;
  width: 100%;
}

/* ── Layout ── */

.page {
  position: relative;
  padding: 2.5rem 2rem;
  border-radius: 1rem;

  --color-h: 200;
  --color-s: 50;
  --color-l: 50;
  background: hsl(
    var(--color-h),
    calc(var(--color-s) * 1%),
    calc(var(--color-l) * 1%)
  );
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.page > *:not(.mood-texture) {
  position: relative;
  z-index: 1;
}

/* ── 1. Header (on green bg) ── */

.header {
  margin-bottom: 1.5rem;
  opacity: 0;
  animation: enter 0.6s 0.05s var(--ease) forwards;
}

.header-title {
  font-family: var(--font-serif);
  font-size: 4rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.header-subtitle {
  font-size: 0.72rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.5;
}

/* ── 2. Date ── */

.date {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: enter 0.6s 0.15s var(--ease) forwards;
}

/* ── 3. Mood word (hero) ── */

.mood-word {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 12vw, 5rem);
  font-weight: 400;
  line-height: 1;
  color: var(--text);
  margin-bottom: 1.25rem;
  opacity: 0;
  animation: enter 0.8s 0.2s var(--ease) forwards;
}

/* ── 4. Metaphor ── */

.vibe {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 30ch;
  margin: 0 auto 3.5rem;
  opacity: 0;
  animation: enter 0.8s 0.3s var(--ease) forwards;
}

/* ── Generative texture ── */

.mood-texture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── 5. Headlines ── */

.headlines {
  text-align: left;
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: enter 0.7s 0.45s var(--ease) forwards;
}

.headlines-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(var(--ink), 0.1);
}

.headlines-title {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.headlines-updated {
  font-size: 0.55rem;
  font-weight: 300;
  color: var(--text-faint);
}

.headline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0;
}

.headline-item + .headline-item {
  border-top: 1px solid rgba(var(--ink), 0.06);
}

.headline-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  margin-top: 0.5rem;
}

.headline-text {
  font-size: 0.78rem;
  font-weight: 300;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ── 7. Footer ── */

.footer {
  margin-top: 2.5rem;
  text-align: center;
  opacity: 0;
  animation: enter 0.7s 0.8s var(--ease) forwards;
}

.footer-about {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.35);
  line-height: 1.5;
}

.footer-credit {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 0.3rem;
}

.footer-credit a {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-credit a:hover {
  color: rgba(255, 255, 255, 0.7);
}

/* ── 8. History (on green bg) ── */

.history {
  margin-top: 1.5rem;
  opacity: 0;
  animation: enter 0.7s 0.6s var(--ease) forwards;
}

.history-label {
  font-size: 0.55rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.6rem;
}

.history-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.history-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  transition: transform 0.15s var(--ease);
  cursor: pointer;
}

.history-dot:hover {
  transform: scale(1.8);
}

.history-dot.is-today {
  outline: 1.5px solid rgba(255, 255, 255, 0.5);
  outline-offset: 1.5px;
}

.history-dot.is-selected {
  transform: scale(1.8);
  outline: 1.5px solid rgba(255, 255, 255, 0.7);
  outline-offset: 1.5px;
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: rgba(var(--ink), 0.7);
  color: var(--toast-color, #fff);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition:
    transform 0.4s var(--ease),
    opacity 0.4s;
  opacity: 0;
  z-index: 10;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Loading skeleton ── */

@keyframes shimmer {
  0% {
    opacity: 0.3;
  }
  50% {
    opacity: 0.6;
  }
  100% {
    opacity: 0.3;
  }
}

body.is-loading .page {
  background: hsl(0, 0%, 20%);
}

body.is-loading .date,
body.is-loading .mood-word,
body.is-loading .vibe,
body.is-loading .headlines,
body.is-loading .history-row {
  visibility: hidden;
}

body.is-loading .date::before,
body.is-loading .mood-word::before,
body.is-loading .vibe::before {
  content: "";
  visibility: visible;
  display: block;
  height: 1em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  animation: shimmer 1.5s ease-in-out infinite;
}

body.is-loading .date::before {
  width: 55%;
}
body.is-loading .mood-word::before {
  width: 40%;
  height: 1.2em;
}
body.is-loading .vibe::before {
  width: 70%;
}

body.is-loading .headlines::before {
  content: "";
  visibility: visible;
  display: block;
  height: 6rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  animation: shimmer 1.5s ease-in-out infinite 0.2s;
}

/* ── Reveal transition ── */

body:not(.is-loading) .page {
  transition: background-color 0.4s var(--ease);
}

body:not(.is-loading) .date,
body:not(.is-loading) .mood-word,
body:not(.is-loading) .vibe,
body:not(.is-loading) .headlines {
  animation: reveal 0.4s var(--ease) both;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Animation ── */

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Accessibility ── */

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

/* ── Responsive ── */

@media (max-width: 480px) {
  body {
    padding: 1rem;
  }
  .page {
    padding: 2rem 1.25rem;
  }
  .mood-word {
    font-size: clamp(2.5rem, 10vw, 4rem);
  }
}
