/* Annika Timer 2.0 — stylesheet
   version = "20260912-143000" */

:root {
  --bg-main: #050509;
  --card-bg: #14151c;
  --card-bg-top: #1e1f2a;
  --accent: #7a63ff;
  --accent-muted: #2b2c3b;
  --accent-warning: #f5a623;
  --text-main: #ffffff;
  --text-sub: #8c8fa8;
  --menu-w: min(320px, 88vw);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #232437 0, var(--bg-main) 55%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  text-align: center;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Layered background effects.
   The tint layer and the flash layer each own their own element, so the
   interval tint and the pre-countdown flash can never overwrite each other. */

.bg-tint {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: transparent;
  transition: background-color 0.45s ease;
  pointer-events: none;
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 1;
  background-color: #ffffff;
  opacity: 0;
  transition: opacity 0.14s ease-out;
  pointer-events: none;
}

.flash.on {
  opacity: 1;
}

.logo {
  position: fixed;
  top: calc(16px + var(--safe-t));
  left: calc(16px + var(--safe-l));
  width: 120px;
  height: auto;
  border-radius: 50%;
  z-index: 10;
}

.timer-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 16px;
}

.timer-card {
  width: 320px;
  max-width: 90vw;
  background: linear-gradient(180deg, var(--card-bg-top), var(--card-bg));
  border-radius: 28px;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.7);
  padding: 28px 16px 32px;
  position: relative;
}

.timer-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.progress-ring-wrapper {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring-svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  stroke: #242533;
  opacity: 0.85;
}

.progress-ring-value {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s ease;
  filter: drop-shadow(0 0 12px rgba(122, 99, 255, 0.7));
}

.time-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#timerDisplay {
  font-size: 2.8rem;
  letter-spacing: 0.05em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#timerSubtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-sub);
}

.status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sub);
}

.controls-row {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.control-button {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background-color: var(--accent-muted);
  color: var(--text-main);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.6);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
}

.control-button.primary {
  background-color: var(--accent-warning);
  color: #151515;
}

.control-button:active {
  transform: translateY(2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
}

.control-button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
  transform: none;
}

/* Visible keyboard focus on every interactive element. */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.menu :focus-visible {
  outline-color: #1a1a1a;
}

.copyright {
  position: fixed;
  bottom: calc(10px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-sub);
  z-index: 11;
  pointer-events: none;
}

/* Side menu (settings) */

.menu {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--menu-w);
  height: 100dvh;
  background-color: #d8d4d4;
  padding: calc(56px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  visibility: hidden;
  opacity: 0;
  transform: translateX(12px);
  transition: visibility 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: #111;
  text-align: left;
  z-index: 40;
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
}

.menu.open {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
}

.menu h2 {
  margin: 24px 0 8px;
  font-size: 1.1rem;
}

.menu h2:first-of-type {
  margin-top: 0;
}

.menu-close-btn {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: #333;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: manipulation;
}

.menu-action {
  margin-top: 18px;
  width: 100%;
  border-radius: 12px;
  padding: 12px;
  border: 0;
  background-color: #333;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}

.menu-action:active {
  background-color: #555;
}

.menu-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #4a4a4a;
}

.toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0;
  gap: 8px;
  font-size: 0.9rem;
}

.toggle-label-up,
.toggle-label-down {
  min-width: 70px;
  text-align: center;
}

.toggle-switch {
  position: relative;
  width: 56px;
  height: 30px;
  flex: 0 0 auto;
}

.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 100%;
  margin: 0;
  background-color: #c6c6c6;
  border-radius: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
  position: relative;
}

.toggle:checked {
  background-color: #8e8ad6;
}

.toggle-indicator {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: #fff;
  top: 2px;
  left: 2px;
  transition: left 0.3s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

#timeInput {
  display: flex;
  margin: 16px 0 10px;
  justify-content: flex-start;
  gap: 10px;
}

.input-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 0.8rem;
}

.input-container label {
  margin-bottom: 4px;
}

.input-container input {
  width: 68px;
  height: 36px;
  font-size: 0.95rem;
  text-align: center;
  border-radius: 8px;
  border: 1px solid #b0b0b0;
  background: #fff;
  color: #111;
}

/* Loading overlay */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 16px;
}

.overlay[hidden] {
  display: none;
}

.overlay-content {
  background-color: #ffffff;
  padding: 22px;
  border-radius: 12px;
  text-align: center;
  color: #121212;
  min-width: 240px;
  max-width: 340px;
}

.overlay-content p {
  margin: 0 0 12px;
}

.load-btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  background: #2b2c3b;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.progress-bar {
  width: 100%;
  max-width: 220px;
  height: 20px;
  background-color: #f3f3f3;
  border-radius: 10px;
  margin: 10px auto;
  overflow: hidden;
}

.progress {
  width: 0%;
  height: 100%;
  background-color: #3498db;
  transition: width 0.3s ease;
}

/* Degraded-audio notice */

.audio-notice {
  position: fixed;
  left: 50%;
  bottom: calc(40px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, 92vw);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(245, 166, 35, 0.14);
  border: 1px solid rgba(245, 166, 35, 0.45);
  color: #f7d08a;
  font-size: 0.78rem;
  text-align: left;
}

.audio-notice[hidden] {
  display: none;
}

.audio-notice button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--accent-warning);
  color: #151515;
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Pre-countdown */

.pre-countdown-display {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pre-countdown-display.visible {
  display: flex;
  animation: preCountPulse 0.25s ease-out;
}

.pre-countdown-number {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-warning);
  text-shadow: 0 0 32px rgba(245, 166, 35, 0.7);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.pre-countdown-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-sub);
}

@keyframes preCountPulse {
  0%   { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

@media (max-width: 480px) {
  .timer-card {
    width: 280px;
    padding: 22px 12px 26px;
  }

  .progress-ring-wrapper {
    width: 200px;
    height: 200px;
  }

  #timerDisplay {
    font-size: 2.4rem;
  }

  .control-button {
    width: 60px;
    height: 60px;
    font-size: 1.4rem;
  }

  .logo {
    width: 90px;
  }
}

@media (max-height: 520px) {
  .logo {
    width: 64px;
  }

  .copyright {
    display: none;
  }
}

/* No flashing, no drifting background tints, no scale-in for anyone who asked
   the OS to keep motion down. */

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

  .flash {
    display: none;
  }
}
