/* ========================================
   SynchroTimer - Styles
   ======================================== */

:root {
  --bg-deep: #06060f;
  --bg-primary: #0a0a1a;
  --bg-card: rgba(14, 14, 36, 0.85);
  --bg-card-border: rgba(255, 255, 255, 0.06);
  --text-primary: #e8e8ff;
  --text-secondary: #7878a0;
  --text-muted: #4a4a6a;
  --accent-cyan: #00e5ff;
  --accent-purple: #7c4dff;
  --accent-green: #00e676;
  --accent-amber: #ffab00;
  --accent-red: #ff1744;
  --glow-cyan: 0 0 30px rgba(0, 229, 255, 0.25);
  --glow-red: 0 0 30px rgba(255, 23, 68, 0.3);
  --glow-amber: 0 0 30px rgba(255, 171, 0, 0.25);
  --radius: 12px;
  --radius-lg: 20px;
}

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

html, body {
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-cyan); text-decoration: none; }

/* ---- Animated background glows ---- */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.3), transparent 70%);
  top: -150px; left: -100px;
  animation: floatGlow1 12s ease-in-out infinite;
}
.bg-glow-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(124, 77, 255, 0.3), transparent 70%);
  bottom: -100px; right: -80px;
  animation: floatGlow2 15s ease-in-out infinite;
}
@keyframes floatGlow1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(60px, 40px); }
}
@keyframes floatGlow2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-50px, -30px); }
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.25);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 30px rgba(0, 229, 255, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, #00c853, #00e676);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 230, 118, 0.3);
}
.btn-success:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(0, 230, 118, 0.45); }

.btn-warning {
  background: linear-gradient(135deg, #ff8f00, #ffab00);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 171, 0, 0.3);
}
.btn-warning:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(255, 171, 0, 0.45); }

.btn-danger {
  background: linear-gradient(135deg, #d50000, #ff1744);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 23, 68, 0.3);
}
.btn-danger:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(255, 23, 68, 0.45); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.btn-ghost:hover { color: var(--text-primary); border-color: rgba(255, 255, 255, 0.15); }

.btn-large { padding: 16px 36px; font-size: 16px; border-radius: 14px; }
.btn-small { padding: 8px 14px; font-size: 12px; }
.btn-control { padding: 14px 28px; font-size: 15px; }

/* ========================================
   LANDING PAGE
   ======================================== */

.landing {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 40px 0;
}

.landing-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px 40px;
  max-width: 460px;
  width: 100%;
}

.logo {
  font-family: 'Orbitron', monospace;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.logo span {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 40px;
  line-height: 1.5;
}

.landing-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  backdrop-filter: blur(20px);
}

.landing-card .btn-large { width: 100%; justify-content: center; }

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.join-form {
  display: flex;
  gap: 10px;
  min-width: 0;
}
.join-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  letter-spacing: 6px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.join-form input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
}
.join-form .btn {
  flex-shrink: 0;
}
.join-form input::placeholder {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--text-muted);
}

.error-text {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 12px;
}

.landing-features {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 40px;
}
.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.feature-icon { font-size: 24px; }

/* ---- About Section (landing) ---- */
.about-section {
  margin-top: 48px;
  text-align: left;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.about-title {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
  text-transform: uppercase;
}

.about-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.about-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.about-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.2);
  color: var(--accent-cyan);
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
}

.about-text strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.about-text p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.about-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  text-align: center;
}

.about-footer p {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ---- Help Modal Content ---- */
.help-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.help-item strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.help-item p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.help-item.help-footer {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  text-align: center;
}

/* ========================================
   TIMER PAGE
   ======================================== */

.timer-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.timer-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(20px);
}

/* ---- Header ---- */
.timer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.logo-small {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-secondary);
}
.logo-small span {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(0, 230, 118, 0); }
}

.timer-id-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  font-size: 12px;
}
.timer-id-badge .label { color: var(--text-muted); }
.timer-id-badge .code {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 2px;
}

/* ---- Timer Display ---- */
.timer-display {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(264px, 55vw, 55vh);
  aspect-ratio: 1;
  margin: 0 auto 24px;
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 6;
}

.progress-bar {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 6;
  stroke-linecap: round;
  filter: url(#glow);
  transition: stroke 0.4s ease;
}

.timer-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.timer-digits {
  font-family: 'Orbitron', monospace;
  font-size: clamp(32px, 12vw, 56px);
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--text-primary);
  text-shadow: 0 0 40px rgba(0, 229, 255, 0.2);
  line-height: 1;
}
.timer-digits .colon {
  opacity: 0.5;
  margin: 0 2px;
}

.timer-status {
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* -- Color states -- */
.timer-display.warning .timer-digits {
  color: var(--accent-amber);
  text-shadow: var(--glow-amber);
}
.timer-display.warning {
  --ring-color-1: var(--accent-amber);
  --ring-color-2: #ff6d00;
}

.timer-display.critical .timer-digits {
  color: var(--accent-red);
  text-shadow: var(--glow-red);
  animation: urgentPulse 0.6s ease-in-out infinite;
}
.timer-display.critical {
  --ring-color-1: var(--accent-red);
  --ring-color-2: #d50000;
}
.timer-display.critical .progress-bar {
  stroke: url(#ringGradient);
}

@keyframes urgentPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* -- Finished state -- */
.timer-display.finished .timer-digits,
.timer-display.finished .times-up {
  color: var(--accent-red);
  text-shadow: var(--glow-red);
}
.timer-display.finished {
  --ring-color-1: var(--accent-red);
  --ring-color-2: #d50000;
}

.times-up {
  font-family: 'Orbitron', monospace;
  font-size: clamp(18px, 6vw, 28px);
  font-weight: 900;
  letter-spacing: 3px;
  animation: finishedFlash 0.5s ease-in-out infinite;
}

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

/* ---- Controls (Host only) ---- */
.controls {
  margin-bottom: 24px;
}

.duration-presets {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  transition: opacity 0.2s;
}

.preset {
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
.preset.active {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.custom-duration {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  transition: opacity 0.2s;
}
.custom-duration label {
  font-size: 12px;
  color: var(--text-muted);
}
.custom-duration input {
  width: 56px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  text-align: center;
  outline: none;
}
.custom-duration input::placeholder {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0;
  color: var(--text-muted);
}
.custom-duration input:focus {
  border-color: var(--accent-cyan);
}
.colon-label {
  color: var(--text-muted);
  font-weight: 600;
}

.control-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ---- Share Section ---- */
.share-section {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.qr-container {
  flex-shrink: 0;
}
.qr-container img {
  display: block;
  border-radius: 8px;
}

.share-info {
  flex: 1;
  min-width: 0;
}

.share-row {
  margin-bottom: 12px;
}
.share-row:last-child { margin-bottom: 0; }
.share-row label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.copy-field {
  display: flex;
  gap: 6px;
}
.copy-field input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  outline: none;
}

.share-code {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
}

/* ---- Header Icon Buttons ---- */
.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.header-icon-btn:hover {
  color: var(--accent-cyan);
  border-color: rgba(0, 229, 255, 0.3);
  background: rgba(0, 229, 255, 0.08);
}
.header-icon-btn.muted {
  color: var(--accent-red);
  border-color: rgba(255, 23, 68, 0.25);
}

/* ---- Error overlay ---- */
.error-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
}
.error-card {
  text-align: center;
  padding: 40px;
}
.error-card h2 {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  margin-bottom: 12px;
  color: var(--accent-red);
}
.error-card p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ========================================
   HOST / GUEST VISIBILITY
   ======================================== */

.is-guest .host-only { display: none !important; }
.is-host .guest-only { display: none !important; }

/* ========================================
   SHARE MODAL
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  animation: modalFadeIn 0.15s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 360px;
  backdrop-filter: blur(20px);
  animation: modalSlideIn 0.2s ease;
}
@keyframes modalSlideIn {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.modal-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.modal-qr img {
  border-radius: 8px;
}

.modal-card .share-row {
  margin-bottom: 16px;
}
.modal-card .share-row:last-child {
  margin-bottom: 0;
}

/* ========================================
   POPUP MODE
   ======================================== */

.popup-mode .timer-container {
  max-width: 100%;
  border: none;
  border-radius: 0;
  background: var(--bg-deep);
}
.popup-mode .share-section { display: none; }

/* ========================================
   PASSWORD / CLAIM UI
   ======================================== */

.password-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.protected-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--accent-amber);
  opacity: 0.8;
  flex-shrink: 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-form input {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.modal-form input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.1);
}
.modal-form input::placeholder {
  color: var(--text-muted);
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.15);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 520px) {
  .timer-container { padding: 20px; }
  .logo { font-size: 30px; }

  .share-section {
    flex-direction: column;
    text-align: center;
  }

  .timer-header {
    flex-direction: column;
    gap: 10px;
  }

  .landing-features {
    gap: 20px;
  }
}
