/* Focus Timer by SWC - Enhanced and flicker safe */

:root{
  --bg:#0a0f1e;
  --panel:#12182a;
  --text:#e7ebff;
  --muted:#9aa6c3;
  --accent:#6b8cff;
  --accent-2:#ff6bd6;
  --ok:#45e0a6;
  --danger:#ff7a7a;

  --radius:18px;
  --shadow:0 10px 30px rgba(0,0,0,0.35);
}

*{ box-sizing: border-box; }
html,body{
  height:100%;
  color:var(--text);
  background:var(--bg);
  font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body{ margin:0; overflow-x:hidden; }

/* Animated background orbs on their own GPU layers, transform + opacity only */
.bg-orb{
  position:fixed;
  inset:0;
  z-index:-1;
  pointer-events:none;
  will-change: transform, opacity;
  transform: translateZ(0);
}
.orb-1::before,
.orb-2::before,
.orb-3::before{
  content:"";
  position:absolute;
  width:120vmax; height:120vmax;
  left:50%; top:50%;
  transform: translate(-50%, -50%);
  border-radius:50%;
  background: radial-gradient(closest-side, rgba(107,140,255,0.25), transparent 70%);
}
.orb-2::before{ background: radial-gradient(closest-side, rgba(255,107,214,0.22), transparent 70%); }
.orb-3::before{ background: radial-gradient(closest-side, rgba(69,224,166,0.18), transparent 70%); }

/* Gentle drift without filter animation */
.orb-1{ animation: orbDrift1 26s ease-in-out infinite; }
.orb-2{ animation: orbDrift2 32s ease-in-out infinite; }
.orb-3{ animation: orbDrift3 38s ease-in-out infinite; }

@keyframes orbDrift1{
  0%,100%{ transform: translate3d(0,0,0); opacity:0.85; }
  50%{ transform: translate3d(2%, -3%, 0) scale(1.02); opacity:1; }
}
@keyframes orbDrift2{
  0%,100%{ transform: translate3d(0,0,0); opacity:0.75; }
  50%{ transform: translate3d(-3%, 2%, 0) scale(1.03); opacity:0.95; }
}
@keyframes orbDrift3{
  0%,100%{ transform: translate3d(0,0,0); opacity:0.7; }
  50%{ transform: translate3d(1%, 2%, 0) scale(1.05); opacity:0.9; }
}

@media (prefers-reduced-motion: reduce){
  .orb-1, .orb-2, .orb-3{ animation: none; opacity:0.6; }
}

/* Layout shell */
.shell{
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 56px;
  position: relative;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.topbar h1{
  font-weight:800;
  letter-spacing:0.2px;
  font-size: clamp(22px, 2.6vw, 32px);
  display:flex; align-items:center; gap:8px;
}
.topbar h1 span{
  font-weight:600;
  font-size: 0.7em;
  color:var(--muted);
}
.controls-right{ display:flex; gap:8px; }

/* Chips for modes */
.modes{
  display:flex; gap:8px; flex-wrap:wrap;
  margin-bottom: 18px;
}
.chip{
  appearance:none; border:0; cursor:pointer;
  padding:10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color:var(--text);
  transition: transform 0.12s ease, background 0.2s ease;
  box-shadow: 0 8px 18px rgba(0,0,0,0.15), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.chip:hover{ transform: translateY(-1px); }
.chip.active{ background: linear-gradient(90deg, rgba(107,140,255,0.22), rgba(255,107,214,0.18)); }

/* Timer card */
.timer-card{
  background: linear-gradient(180deg, rgba(18,24,42,0.9), rgba(18,24,42,0.7));
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ring{
  width: 300px;
  height: 300px;
  margin: 12px auto 18px;
  border-radius: 50%;
  position: relative;
  display:grid; place-items:center;
  --progress: 0deg;
  background:
    conic-gradient(from -90deg, var(--accent) 0 var(--progress), rgba(255,255,255,0.08) var(--progress) 360deg);
  -webkit-mask: radial-gradient(circle 128px at 50% 50%, transparent 127px, #000 128px);
          mask: radial-gradient(circle 128px at 50% 50%, transparent 127px, #000 128px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 12px 30px rgba(0,0,0,0.35);
}
.ring-inner{
  width: 236px; height: 236px;
  border-radius: 50%;
  display:grid; place-items:center;
  background: radial-gradient(120px 120px at 50% 35%, rgba(255,255,255,0.06), rgba(255,255,255,0.02) 70%);
}

.time{ font-size: 58px; font-weight: 800; letter-spacing: 1px; }
.time .sep{ opacity:0.9; }

.label{ margin-top: 8px; color: var(--muted); font-weight: 600; text-align: center; }

/* Linear progress */
.progress-wrap{
  width:100%;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 18px;
}
.progress{
  width:0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Actions */
.actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }

.btn{
  appearance:none; border:0; cursor:pointer;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18), inset 0 0 0 1px rgba(255,255,255,0.06);
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn.primary{
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #0b0f1d;
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}
.btn.ghost{ background: rgba(255,255,255,0.06); }

/* Hints */
.hints{
  display:flex; gap: 12px; justify-content:center;
  color: var(--muted);
  font-size: 13px;
  flex-wrap:wrap;
}

/* Stats */
.stats{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}
.stat{
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 16px;
  text-align:center;
  box-shadow: 0 8px 18px rgba(0,0,0,0.16), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.stat-number{ font-size: 28px; font-weight: 800; }
.stat-label{ color: var(--muted); font-weight: 600; font-size: 12px; }

/* Pro row */
.pro{ background: rgba(255,255,255,0.05); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.panel-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.panel-row.small{ margin-top:8px; color: var(--muted); }
.inline{ display:flex; align-items:center; gap:8px; font-weight:600; }

/* Footer */
.foot{
  display:flex; align-items:center; justify-content: space-between; gap: 16px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}
.foot a{ color: var(--text); opacity: 0.9; text-decoration: underline; }

/* Dialog styling and stable backdrop */
dialog{
  border: none;
  border-radius: 16px;
  padding: 0;
  background: linear-gradient(180deg, rgba(18,24,42,0.98), rgba(18,24,42,0.92));
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.panel{ padding: 16px; min-width: 480px; }
.panel-head{ display:flex; align-items:center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2{ margin: 0; }
.grid{ display:grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap:12px; }
.grid label{ display:grid; gap:6px; font-weight:600; color: var(--muted); }
.grid input[type="number"], .grid input[type="range"]{
  background: rgba(255,255,255,0.06); color: var(--text); border: none; border-radius: 10px; padding: 10px 12px; font-weight:700;
}
.panel-foot{ display:flex; gap:10px; justify-content:flex-end; margin-top: 12px; }

dialog::backdrop{
  background: rgba(10,15,30,0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  will-change: opacity;
  transition: opacity 0.25s ease;
}

/* Responsive */
@media (max-width: 640px){
  .ring{ width: 260px; height: 260px; -webkit-mask: radial-gradient(circle 110px at 50% 50%, transparent 110px, #000 111px); mask: radial-gradient(circle 110px at 50% 50%, transparent 110px, #000 111px); }
  .ring-inner{ width: 200px; height: 200px; }
  .time{ font-size: 46px; }
  .panel{ min-width: 320px; }
  .grid{ grid-template-columns: 1fr; }
}
