/* 
   RazynLab — Take a Break Styling
   Calm Interface and Pomodoro Widget Stylesheet
*/

.calm-body {
  overflow: hidden !important;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* shrinks when Safari URL bar is visible */
  position: relative;
  background: #000000;
}

#calm-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none; /* Prevents mobile browser viewport elastic dragging */
}

/* Nav bar overlay override */
.calm-nav {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0));
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ---------- Mode Selector: compact trigger + collapsible panel ---------- */
.mode-selector {
  position: absolute;
  bottom: 32px;
  right: 32px;
  display: flex;
  flex-direction: column;   /* .mode-panel on top, trigger at bottom */
  width: 220px;
  background: rgba(8, 8, 8, 0.88);
  border: 1px solid var(--line2);
  z-index: 10;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 6px;
  overflow: hidden;
}

/* Panel — hidden until panel-open */
.mode-panel {
  display: none;
  flex-direction: column;
}

.mode-selector.panel-open .mode-panel {
  display: flex;
}

/* Mode buttons — list rows inside the panel */
.mode-btn {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--muted);
  padding: 10px 16px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  border-radius: 0;
  width: 100%;
}

.mode-btn:last-child {
  border-bottom: none;
}

.mode-btn:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.04);
}

.mode-btn.active {
  color: #ffffff;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
}

/* Trigger row — always visible, anchors panel at bottom */
.mode-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  width: 100%;
  transition: background 0.15s ease;
}

.mode-menu-toggle:hover {
  background: rgba(255,255,255,0.03);
}

/* mode-label replaced by toggle text */
.mode-label {
  display: none;
}

.mode-toggle-arrow {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.25s ease;
}

.mode-selector.panel-open .mode-toggle-arrow {
  transform: rotate(180deg);
}

/* Sub-menu dismiss × button (desktop only) */
.sub-dismiss-btn {
  position: absolute;
  top: 5px;
  right: 7px;
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 5px;
  font-family: inherit;
  transition: color 0.15s ease;
  z-index: 1;
}

.sub-dismiss-btn:hover {
  color: #ffffff;
}

/* Backdrop blur overlay for mobile settings modal */
.timer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.timer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Pomodoro Timer Card (Top Left) ---------- */
.timer-card {
  position: absolute;
  top: 100px;
  left: 32px;
  width: 290px;
  background: rgba(5, 5, 5, 0.72);
  border: 1px solid var(--line2);
  padding: 24px;
  z-index: 10;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Collapsed state — full card hides, shows compact digits pill */
.timer-card.collapsed {
  gap: 0;
}
.timer-card.collapsed .timer-display,
.timer-card.collapsed .timer-settings,
.timer-card.collapsed .timer-stats,
.timer-card.collapsed .timer-actions,
.timer-card.collapsed .calm-tip {
  display: none !important;
}
.timer-card.collapsed .timer-compact-digits {
  display: inline-block !important;
}

.timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.timer-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timer-state {
  font-size: 10px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  border: 1px solid rgba(255,255,255,0.05);
}

/* Circular Timer Display */
.timer-display {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-indicator {
  transition: stroke-dashoffset 0.1s linear;
  transform-origin: 65px 65px;
}

.timer-digits {
  position: absolute;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255,255,255,0.15);
}

/* Adjust Settings Inputs */
.timer-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.settings-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-label {
  font-size: 12px;
  color: var(--muted);
}

.settings-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.adjust-btn {
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--muted);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s;
  border-radius: 2px;
}

.adjust-btn:hover {
  color: #ffffff;
  border-color: var(--muted);
  background: rgba(255,255,255,0.03);
}

.adjust-val {
  font-size: 13px;
  font-weight: 500;
  width: 22px;
  text-align: center;
  color: #ffffff;
}

/* Action Buttons */
.timer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.timer-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--fg);
  padding: 9px 0;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  border-radius: 3px;
  text-align: center;
  font-weight: 500;
}

.timer-btn:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--muted);
}

.timer-btn.primary {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.timer-btn.primary:hover {
  background: rgba(255, 255, 255, 0.85);
  color: #000000;
}

.timer-btn.icon-btn {
  flex: 0 0 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sound-icon {
  font-size: 14px;
}

/* Calm Help Tips */
.calm-tip {
  font-size: 10px;
  color: var(--faint);
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.4;
  margin-top: 4px;
}

/* ---------- Responsive Layouts ---------- */
@media(max-width: 768px) {
  /* Collapsed pill — top-right corner capsule */
  .timer-card.collapsed {
    top: 76px !important;
    right: 16px !important;
    left: auto !important;
    width: auto !important;
    max-width: fit-content !important;
    padding: 6px 12px !important;
    border-radius: 20px !important;
    gap: 0 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
    background: rgba(10,10,10,0.85) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    position: absolute !important;
    transform: none !important;
  }

  .timer-card.collapsed .timer-header-controls {
    gap: 6px !important;
  }

  .timer-card.collapsed .timer-label {
    display: none !important;
  }

  .timer-card.collapsed .timer-state {
    font-size: 9px !important;
    padding: 2px 5px !important;
  }

  /* Expanded = centred modal */
  .timer-card {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    right: auto !important;
    bottom: auto !important;
    width: calc(100% - 32px) !important;
    max-width: 300px !important;
    margin: 0 !important;
    padding: 20px 24px !important;
    gap: 16px !important;
    border-radius: 6px !important;
    z-index: 10 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8) !important;
    background: rgba(8,8,8,0.95) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
  }

  .calm-nav .nav-links {
    display: flex !important;
  }

  /* Mode selector: full width on mobile */
  .mode-selector {
    bottom: calc(20px + env(safe-area-inset-bottom, 20px));
    left: 16px;
    right: 16px;
    transform: none;
    width: auto;
  }

  /* Dismiss × not needed on mobile — panel handles navigation */
  .sub-dismiss-btn {
    display: none;
  }
}

/* Hide sub-menus while mode panel is open — applies on all screen sizes */
body.mode-panel-open .breath-pattern-selector,
body.mode-panel-open #ambient-mixer-panel,
body.mode-panel-open #flow-sub-selector {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

@media(max-height: 600px) {
  /* Prevent overlap on landscapes */
  .timer-card {
    position: relative;
    top: 80px;
    left: 20px;
    width: 250px;
    padding: 12px;
    gap: 10px;
  }
  .progress-ring {
    width: 80px;
    height: 80px;
  }
  .progress-ring circle {
    r: 34;
    cx: 40;
    cy: 40;
  }
  .timer-digits {
    font-size: 18px;
  }
}

/* ---------- Fullscreen Welcome Splash Screen ---------- */
#calm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 1000; /* Overrides nav and widgets */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#calm-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-content {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ---------- Breath Pattern Selector (Bottom Center) ---------- */
.breath-pattern-selector {
  position: absolute;
  bottom: 104px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 10, 10, 0.75);
  border: 1px solid var(--line2);
  padding: 4px 10px;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 4px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.pattern-label {
  font-size: 10px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-right: 6px;
  border-right: 1px solid var(--line2);
}

.pattern-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 2px;
}

.pattern-btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.03);
}

.pattern-btn.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-weight: 500;
}

@media(max-width: 768px) {
  .breath-pattern-selector {
    position: absolute;
    bottom: calc(76px + env(safe-area-inset-bottom, 20px));
    left: 16px;
    right: 16px;
    transform: none;
    justify-content: center;
    gap: 2px;
    padding: 3px 6px;
  }
  .pattern-label {
    display: none;
  }
  .pattern-btn {
    padding: 4px 8px;
    font-size: 10px;
  }
}

/* ---------- Ambient Mixer Styles ---------- */
#ambient-mixer-panel {
  position: absolute;
  bottom: 104px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--line2);
  border-radius: 6px;
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  z-index: 100;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.mixer-channel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 60px;
}

.mixer-icon {
  font-size: 16px;
  margin-bottom: 8px;
  user-select: none;
}

.mixer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 6px;
  height: 100px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
  border: none;
  writing-mode: vertical-lr;
}

.mixer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
  transition: transform 0.15s ease;
}

.mixer-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.mixer-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
  border: none;
}

.mixer-label {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 8px;
  color: var(--muted);
  text-transform: lowercase;
}

@media(max-width: 768px) {
  #ambient-mixer-panel {
    position: absolute;
    bottom: calc(76px + env(safe-area-inset-bottom, 20px));
    left: 16px;
    right: 16px;
    transform: none;
    justify-content: center;
    gap: 8px;
    padding: 12px 10px;
  }
  .mixer-slider {
    height: 80px;
  }
}

/* ---------- Sensory Flow Styles ---------- */
#flow-sub-selector {
  position: absolute;
  bottom: 104px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 10, 10, 0.75);
  border: 1px solid var(--line2);
  padding: 4px 10px;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 4px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sub-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 2px;
}

.sub-btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.03);
}

.sub-btn.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-weight: 500;
}

@media(max-width: 768px) {
  #flow-sub-selector {
    position: absolute;
    bottom: calc(76px + env(safe-area-inset-bottom, 20px));
    left: 16px;
    right: 16px;
    transform: none;
    justify-content: center;
    gap: 2px;
    padding: 3px 6px;
  }
  .sub-btn {
    padding: 4px 8px;
    font-size: 10px;
  }
}
