/* ==========================================================================
   Personal Memory Timer — Dark luxury emotional theme
   ========================================================================== */

/* --- Reset & base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Color palette */
  --bg-deep: #07060b;
  --bg-mid: #0f0d18;
  --text-primary: #f0ece8;
  --text-muted: rgba(240, 236, 232, 0.55);
  --text-soft: rgba(240, 236, 232, 0.75);
  --accent-warm: #c9a87c;
  --accent-glow: rgba(201, 168, 124, 0.25);
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.07);

  /* Typography */
  --font-display: "Cormorant Garamond", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Spacing */
  --section-gap: clamp(3rem, 8vw, 6rem);
  --card-radius: 1.25rem;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 300;
  color: var(--text-primary);
  background: var(--bg-deep);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Animated background --- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(60, 40, 90, 0.35) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(120, 80, 50, 0.15) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 10% 70%, rgba(40, 50, 100, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
}

/* Floating glowing orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: orbFloat 18s ease-in-out infinite;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(140, 100, 180, 0.35), transparent 70%);
  top: -10%;
  left: 20%;
  animation-delay: 0s;
}

.orb-2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(201, 168, 124, 0.2), transparent 70%);
  bottom: 10%;
  right: -5%;
  animation-delay: -6s;
}

.orb-3 {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(80, 100, 160, 0.25), transparent 70%);
  top: 50%;
  left: -8%;
  animation-delay: -12s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -25px) scale(1.05); }
  66%       { transform: translate(-20px, 20px) scale(0.95); }
}

.particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* --- Page layout --- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 2.5rem) clamp(5rem, 10vw, 7rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--section-gap);
}

.section {
  width: 100%;
  text-align: center;
}

/* Entrance animation */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  animation: fadeInUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Hero --- */
.hero {
  padding-top: clamp(1rem, 4vw, 3rem);
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: clamp(0.7rem, 1.8vw, 0.8rem);
  font-weight: 400;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent-warm);
  margin-bottom: 1.75rem;
  opacity: 0.85;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--text-primary) 30%, rgba(201, 168, 124, 0.85) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  color: var(--text-soft);
  max-width: 36rem;
  margin: 0 auto;
  line-height: 1.75;
  font-weight: 300;
}

/* --- Timer cards --- */
.timer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.85rem, 2.5vw, 1.25rem);
  width: 100%;
}

@media (min-width: 640px) {
  .timer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.timer-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  padding: clamp(1.5rem, 4vw, 2.25rem) clamp(1rem, 3vw, 1.5rem);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.4s ease,
              background 0.4s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.timer-card:hover {
  transform: translateY(-6px);
  background: var(--glass-hover);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 30px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.timer-value {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.25rem);
  font-weight: 500;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.timer-label {
  font-size: clamp(0.6rem, 1.5vw, 0.72rem);
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Emotional note --- */
.emotional-note {
  max-width: 28rem;
  margin: 0 auto;
  border: none;
  padding: 0;
}

.emotional-note p {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
  font-style: italic;
  font-weight: 400;
  color: var(--text-soft);
  line-height: 1.65;
}

.emotional-note p + p {
  margin-top: 0.5rem;
}

/* --- Hidden letter --- */
.letter-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.letter-trigger {
  font-family: var(--font-body);
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-warm);
  background: transparent;
  border: 1px solid rgba(201, 168, 124, 0.35);
  border-radius: 999px;
  padding: 0.9rem 2rem;
  cursor: pointer;
  transition: background 0.35s ease, border-color 0.35s ease, transform 0.35s ease, box-shadow 0.35s ease;
}

.letter-trigger:hover {
  background: rgba(201, 168, 124, 0.08);
  border-color: rgba(201, 168, 124, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(201, 168, 124, 0.12);
}

.letter-trigger:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 4px;
}

.letter-panel {
  width: 100%;
  max-width: 34rem;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.8s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.6s ease,
              margin-top 0.6s ease;
  margin-top: 0;
}

.letter-panel.is-visible {
  max-height: 24rem;
  opacity: 1;
  margin-top: 0.5rem;
}

.letter-panel-inner {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  padding: clamp(2rem, 5vw, 2.75rem) clamp(1.5rem, 4vw, 2.5rem);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(16px);
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

.letter-panel.is-visible .letter-panel-inner {
  transform: translateY(0);
}

.letter-panel-inner p {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.8vw, 1.3rem);
  font-weight: 400;
  color: var(--text-soft);
  line-height: 1.75;
}

.letter-panel-inner p + p {
  margin-top: 0.75rem;
}

/* --- Footer --- */
.footer p {
  font-size: clamp(0.75rem, 1.8vw, 0.85rem);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Music button --- */
.music-btn {
  position: fixed;
  bottom: clamp(1.25rem, 4vw, 2rem);
  right: clamp(1.25rem, 4vw, 2rem);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-soft);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  animation: musicPulse 3s ease-in-out infinite;
}

.music-btn:hover {
  background: var(--glass-hover);
  transform: scale(1.04);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
}

.music-btn:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 3px;
}

.music-btn.is-playing {
  animation: none;
  border-color: rgba(201, 168, 124, 0.3);
}

@keyframes musicPulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(201, 168, 124, 0);
  }
  50% {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 8px rgba(201, 168, 124, 0.08);
  }
}

.music-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent-warm);
}

.music-icon svg {
  width: 100%;
  height: 100%;
}

/* Hide label on very small screens */
@media (max-width: 380px) {
  .music-label {
    display: none;
  }

  .music-btn {
    padding: 0.85rem;
    border-radius: 50%;
  }
}

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

  .fade-in {
    opacity: 1;
    transform: none;
  }
}
