/* StandBy Mode Pro - Widgets & Layouts Stylesheet */

/* Main Stage Container */
#main-stage {
  flex: 1;
  width: 100%;
  height: 100%;
  /*
   * `min-height: 0` is what makes this a stable box.
   *
   * A flex item defaults to `min-height: auto`, which means it is sized by its
   * CONTENT and will not shrink below it. So the moment the clock and widgets
   * mounted, the stage grew to fit them and pushed the header and navigation
   * down - which is what Lighthouse measured as a 0.346 cumulative layout shift
   * on <main id="main-stage"> once the page started painting before the clock
   * existed.
   *
   * Zero lets the stage shrink into the space the flex container actually has,
   * which is what `flex: 1` was asking for all along. `overflow: hidden` below
   * then clips anything that genuinely does not fit, rather than letting it
   * resize the layout.
   */
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem 1.5rem;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   LAYOUT MODES: STANDALONE, DUO, QUAD
   ========================================================================== */
.layout-standalone {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.layout-duo {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 2.5vw, 2.5rem);
  align-items: stretch;
}

.layout-quad {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: clamp(0.75rem, 1.8vw, 1.75rem);
  align-items: stretch;
}

@media (max-width: 768px) and (orientation: portrait) {
  .layout-duo {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1rem;
  }
  .layout-quad {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0.5rem;
  }
}

/* Widget Card Surface */
.widget-panel {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--card-radius);
  background: var(--bg-surface);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.widget-panel:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.widget-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem 1.25rem;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   WIDGETS
   ========================================================================== */

/* 1. Weather Widget */
.weather-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  width: 100%;
}

.weather-temp-main {
  font-family: var(--font-sans);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
}

.weather-condition {
  font-size: 1.1rem;
  font-weight: 600;
  color: #93c5fd;
}

.weather-forecast-row {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.weather-mini-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* 2. Universal Media Player with Lyrics */
.media-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.media-track-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.media-artwork {
  width: clamp(3.5rem, 8vw, 5.5rem);
  height: clamp(3.5rem, 8vw, 5.5rem);
  border-radius: 1rem;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.media-text h4 {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  color: #fff;
}

.media-text p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.media-lyrics-box {
  flex: 1;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.lyrics-active-line {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 700;
  color: #38bdf8;
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
  transition: all 0.3s ease;
}

.lyrics-next-line {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.media-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

/* 3. Timer & Stopwatch */
.timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.timer-digits {
  font-family: var(--font-mono);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.03em;
}

.timer-btn-row {
  display: flex;
  gap: 0.75rem;
}

/* 4. Calendar & Agenda */
.calendar-widget-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
  font-size: 0.85rem;
}

.calendar-day-header {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding-bottom: 0.25rem;
}

.calendar-day-cell {
  padding: 0.4rem 0.2rem;
  border-radius: 0.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease;
}

.calendar-day-cell.today {
  background: var(--accent-color);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* 5. TODO & Habits */
.todo-list-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.todo-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.todo-item-row.completed {
  opacity: 0.5;
  text-decoration: line-through;
}

/* 6. Tally Counter */
.tally-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tally-number {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 10vw, 7rem);
  font-weight: 900;
  color: #10b981;
  text-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
}

/* 7. Smart Photo Frame */
.photo-frame-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.photo-frame-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 1s ease-in-out, transform 8s ease-out;
}

.photo-frame-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 60%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.25rem;
}

/* ==========================================================================
   NIGHT MODE, OLED BURN-IN & SCREENSAVER
   ========================================================================== */

/* Night Mode Red/Amber Tint */
body.night-mode {
  --bg-primary: #000000;
  --bg-surface: rgba(18, 5, 5, 0.85);
  --text-primary: #ff3b30;
  --text-secondary: #cc2a20;
  --text-muted: #881a14;
  --accent-color: #ff3b30;
  --accent-glow: rgba(255, 59, 48, 0.4);
  filter: contrast(1.1) brightness(0.75);
}

body.night-mode .flip-unit,
body.night-mode .flip-card-top,
body.night-mode .flip-card-bottom,
body.night-mode .flip-leaf {
  background: #140505 !important;
  color: #ff3b30 !important;
  box-shadow: 0 0 15px rgba(255, 59, 48, 0.15);
}

body.night-mode .neon-time {
  color: #ff3b30 !important;
  text-shadow: 0 0 15px #ff3b30, 0 0 30px #ff3b30 !important;
}

/* OLED Burn-In Sub-Pixel Micro Shifting */
.burn-in-shifted {
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Floating Screensaver Mode */
#screensaver-layer {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}

#screensaver-layer.active {
  opacity: 1;
  pointer-events: auto;
}

.screensaver-float-content {
  animation: floatScreensaver 24s ease-in-out infinite alternate;
}

@keyframes floatScreensaver {
  0%   { transform: translate(-20vw, -15vh) scale(0.9); }
  25%  { transform: translate(15vw, -10vh) scale(1); }
  50%  { transform: translate(-10vw, 15vh) scale(0.95); }
  75%  { transform: translate(20vw, 10vh) scale(1.02); }
  100% { transform: translate(-15vw, -10vh) scale(0.9); }
}




/* ==========================================================================
   POMODORO FULL-SCREEN FOCUS STAGE & THEMED CORNER CLOCK (POLISHED)
   ========================================================================== */
.pomo-focus-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
}

/* Elegant Pill Corner Live Clock */
.pomo-corner-clock {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
  background: rgba(18, 18, 24, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 25;
  transition: all 0.25s ease;
}

.pomo-corner-clock:hover {
  background: rgba(28, 28, 36, 0.9);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.pomo-corner-time {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.pomo-corner-date {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  padding-left: 0.6rem;
}

/* Central Focus Container Card */
.pomo-center-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 2.5rem;
  background: rgba(16, 16, 22, 0.65);
  backdrop-filter: blur(32px) saturate(190%);
  -webkit-backdrop-filter: blur(32px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2.25rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  width: 100%;
  max-width: 520px;
  animation: pomoPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stage Toggle Pills Header */
.pomo-stage-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  margin-bottom: 0.75rem;
}

.pomo-stage-btn {
  padding: 0.45rem 1.1rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  border: none;
  background: transparent;
}

.pomo-stage-btn:hover {
  color: #ffffff;
}

.pomo-stage-btn.active-focus {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.pomo-stage-btn.active-short {
  background: #059669;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.45);
}

.pomo-stage-btn.active-long {
  background: #7c3aed;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45);
}

/* Session Cycle Indicator */
.pomo-cycle-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Circular Timer Viewport */
.pomo-circle-wrapper {
  position: relative;
  width: 270px;
  height: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.5rem 0 1rem;
}

.pomo-svg-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: rotate(-90deg);
}

.pomo-digits-box {
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

.pomo-primary-time {
  font-family: var(--font-sans);
  font-size: clamp(3.2rem, 7.5vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.pomo-stage-subtitle {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 0.35rem;
}

/* Presets Bar */
.pomo-presets-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.pomo-preset-chip {
  padding: 0.35rem 0.85rem;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  transition: all 0.15s ease;
  cursor: pointer;
}

.pomo-preset-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Action Controls Bar */
.pomo-controls-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.pomo-btn-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 2.25rem;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.pomo-btn-main:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.pomo-btn-main:active {
  transform: translateY(1px);
}

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


/* ==========================================================================
   ZEN FOCUS AUTO-FADE MODE & TAP-TO-REVEAL
   ========================================================================== */
#top-bar,
#ambient-canvas-layer,
.pomo-stage-nav,
.pomo-cycle-row,
.pomo-presets-bar,
.pomo-center-card,
.pomo-circle-wrapper,
.pomo-corner-clock,
.pomo-controls-bar {
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.5s ease,
              border-color 0.5s ease,
              box-shadow 0.5s ease,
              filter 0.5s ease;
}

/* Zen Active State: Fade out everything except timer, corner clock & playback */
.zen-focus-active #top-bar,
.zen-focus-active #ambient-canvas-layer,
.zen-focus-active .pomo-stage-nav,
.zen-focus-active .pomo-cycle-row,
.zen-focus-active .pomo-presets-bar,
.zen-focus-active #pomo-btn-settings {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-10px);
}

.zen-focus-active .pomo-center-card {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.zen-focus-active .pomo-circle-wrapper {
  transform: scale(1.08);
  filter: drop-shadow(0 0 45px rgba(59, 130, 246, 0.35));
}

.zen-focus-active .pomo-corner-clock {
  opacity: 0.8;
  background: rgba(12, 12, 16, 0.5) !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
}

/* Tap-to-Reveal (Peek) Override: Temporarily restores full UI */
.zen-focus-active.zen-peek-active #top-bar,
.zen-focus-active.zen-peek-active #ambient-canvas-layer,
.zen-focus-active.zen-peek-active .pomo-stage-nav,
.zen-focus-active.zen-peek-active .pomo-cycle-row,
.zen-focus-active.zen-peek-active .pomo-presets-bar,
.zen-focus-active.zen-peek-active #pomo-btn-settings {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(0) !important;
}

.zen-focus-active.zen-peek-active .pomo-center-card {
  background: rgba(16, 16, 22, 0.65) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  backdrop-filter: blur(32px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(190%) !important;
}

.zen-focus-active.zen-peek-active .pomo-circle-wrapper {
  transform: scale(1);
  filter: none;
}
