/* ============================================================
   AARON'S DAILY DINNER DIGEST — style.css
   Mobile-first theming with CSS Custom Properties
   ============================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Colors */
  --primary: #6C5CE7;
  --primary-light: #a29bfe;
  --secondary: #00CEC9;
  --secondary-light: #55efc4;
  --accent: #FDCB6E;
  --accent-warm: #e17055;
  --danger: #d63031;
  --success: #00b894;

  /* Backgrounds */
  --bg-dark: #0f0e17;
  --bg-dark-2: #1a1a2e;
  --bg-card: rgba(255, 255, 255, 0.08);
  --bg-card-hover: rgba(255, 255, 255, 0.14);
  --bg-glass: rgba(255, 255, 255, 0.05);

  /* Text */
  --text-primary: #fffffe;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);

  /* Typography */
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-title: clamp(1.6rem, 5vw, 2.4rem);
  --fs-period: clamp(2.2rem, 8vw, 3.5rem);
  --fs-subject: clamp(1.4rem, 5vw, 2rem);
  --fs-detail: clamp(1rem, 3.5vw, 1.2rem);
  --fs-body: clamp(0.9rem, 3vw, 1rem);
  --fs-small: clamp(0.75rem, 2.5vw, 0.85rem);

  /* Spacing */
  --space-xs: 0.4rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* Borders & Radius */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 50px;

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-button: 0 4px 15px rgba(0, 0, 0, 0.3);
  --shadow-glow-primary: 0 0 30px rgba(108, 92, 231, 0.3);
  --shadow-glow-secondary: 0 0 30px rgba(0, 206, 201, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 300ms ease;
  --transition-slow: 500ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Progress Bar ---------- */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: var(--bg-dark-2);
  z-index: 1000;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
  background-size: 200% 100%;
  animation: progressShimmer 3s ease infinite;
  border-radius: 0 3px 3px 0;
  transition: width var(--transition-base);
}

@keyframes progressShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---------- Animated Background ---------- */
.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-emoji {
  position: absolute;
  font-size: 2rem;
  opacity: 0.08;
  animation: floatUp linear infinite;
  will-change: transform;
}

@keyframes floatUp {
  0% {
    transform: translateY(110vh) rotate(0deg) scale(1);
    opacity: 0;
  }
  10% {
    opacity: 0.08;
  }
  90% {
    opacity: 0.08;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg) scale(1.2);
    opacity: 0;
  }
}

/* Gradient overlay for depth */
.bg-gradient-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 206, 201, 0.1) 0%, transparent 50%);
}

/* ---------- App Container ---------- */
.app-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  padding: var(--space-md);
  padding-top: calc(5px + var(--space-md));
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  padding: var(--space-md) 0;
}

.app-title {
  font-size: var(--fs-title);
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-warm), var(--primary-light));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition-fast);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.app-title:active {
  transform: scale(0.97);
}

.app-subtitle {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: var(--space-xs);
  font-weight: 400;
}

/* ---------- Controls Row ---------- */
.controls-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
}

.control-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: var(--fs-body);
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23ffffff80' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  /* Prevent long voice names from overflowing */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}

.control-select:focus {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.control-select option {
  background: var(--bg-dark-2);
  color: var(--text-primary);
}

/* ---------- Day Display ---------- */
.day-display {
  text-align: center;
  font-size: var(--fs-detail);
  font-weight: 700;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

/* ---------- Period Card ---------- */
.period-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  height: 280px;
  position: relative;
  overflow: hidden;
}

.period-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.period-card:active {
  transform: scale(0.98);
  background: var(--bg-card-hover);
}

.period-card.is-break {
  border-color: rgba(253, 203, 110, 0.3);
}

.period-card.is-break::before {
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
}

.period-card.is-lunch {
  border-color: rgba(0, 184, 148, 0.3);
}

.period-card.is-lunch::before {
  background: linear-gradient(90deg, var(--success), var(--secondary));
}

.period-number {
  font-size: var(--fs-period);
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.period-number.is-break-lunch {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
}

.period-emoji {
  font-size: 2.5rem;
  margin-bottom: var(--space-xs);
}

.period-subject {
  font-size: var(--fs-subject);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.period-detail {
  font-size: var(--fs-detail);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.period-detail .detail-icon {
  font-size: 1rem;
  opacity: 0.7;
}

.period-detail.hidden {
  display: none;
}

/* Period card entrance animation */
.period-card.animate-in {
  animation: cardSlideIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardSlideIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Navigation Buttons ---------- */
.nav-buttons {
  display: flex;
  gap: var(--space-md);
  width: 100%;
  padding-bottom: var(--space-md);
}

.nav-btn {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: var(--fs-detail);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 56px;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.nav-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background var(--transition-fast);
}

.nav-btn:active::after {
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn-back {
  background: linear-gradient(135deg, #2d3436, #636e72);
  color: var(--text-primary);
  box-shadow: var(--shadow-button);
}

.nav-btn-forward {
  background: linear-gradient(135deg, var(--primary), #a29bfe);
  color: var(--text-primary);
  box-shadow: var(--shadow-button), var(--shadow-glow-primary);
}

.nav-btn:active {
  transform: scale(0.96);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.nav-btn:disabled::after {
  display: none;
}

.nav-btn-icon {
  font-size: 1.3rem;
}

/* ---------- Confetti ---------- */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall linear forwards;
  will-change: transform;
}

.confetti-piece.circle {
  border-radius: 50%;
}

.confetti-piece.square {
  border-radius: 2px;
}

.confetti-piece.star {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid currentColor;
  background: none !important;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* End of day overlay */
.end-of-day-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.end-of-day-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.end-of-day-text {
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  font-weight: 900;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-warm), var(--primary-light));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: celebratePulse 1s ease infinite;
  padding: 0 var(--space-md);
}

.end-of-day-emoji {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  animation: celebrateBounce 0.6s ease infinite alternate;
}

.end-of-day-dismiss {
  margin-top: var(--space-lg);
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: var(--fs-body);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.end-of-day-dismiss:active {
  transform: scale(0.95);
}

@keyframes celebratePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes celebrateBounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-15px); }
}

/* ---------- TTS Speaking Indicator ---------- */
.speaking-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--fs-small);
  color: var(--secondary);
  font-weight: 600;
  height: 28px;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.speaking-indicator.active {
  visibility: visible;
  opacity: 1;
}

.speaking-dot {
  width: 6px;
  height: 6px;
  background: var(--secondary);
  border-radius: 50%;
  animation: speakingPulse 1.2s ease infinite;
}

.speaking-dot:nth-child(2) { animation-delay: 0.2s; }
.speaking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes speakingPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.5); opacity: 1; }
}

/* ---------- Tap Hint ---------- */
.tap-hint {
  font-size: var(--fs-small);
  color: var(--text-muted);
  text-align: center;
  font-weight: 400;
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: var(--space-sm) 0 var(--space-lg);
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* ---------- Utility ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
