/* Projeto #13 — Pomodoro com Métricas de Estudo
   HTML5 + CSS3 + Vanilla JS. Sem sombras em textos (regra de tipografia da rubrica). */

:root {
  --bg: #070b14;
  --bg-soft: #0e1524;
  --card: #111a2b;
  --card-2: #16213a;
  --line: #23304a;
  --text: #eaf1fb;
  --text-soft: #9fb0c9;
  --accent: #22d3ee;
  --accent-strong: #06b6d4;
  --focus: #22d3ee;
  --short: #34d399;
  --long: #a78bfa;
  --danger: #fb7185;
  --radius: 18px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(167, 139, 250, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, p, span, label, button, input, select, summary, dd, dt, output, li {
  text-shadow: none;
  filter: none;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  background: var(--accent);
  color: #04121a;
  padding: 0.6rem 1rem;
  border-radius: 0 0 10px 0;
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 13, 23, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), #6366f1);
  color: #04121a;
  font-size: 1.4rem;
  font-weight: 900;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; letter-spacing: 0.01em; }
.brand-text span { font-size: 0.8rem; color: var(--text-soft); }

.auth { display: flex; align-items: center; gap: 0.75rem; }
.profile { display: flex; align-items: center; gap: 0.6rem; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(34, 211, 238, 0.55);
  background: var(--card-2);
}
.profile-name { font-weight: 700; font-size: 0.92rem; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.62rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn:hover { background: #1d2b47; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(34, 211, 238, 0.75);
  outline-offset: 2px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: #04121a;
  min-width: 128px;
}
.btn-primary:hover { background: linear-gradient(135deg, #67e8f9, #22d3ee); }
.btn-ghost { background: transparent; }
.btn-small { padding: 0.4rem 0.85rem; font-size: 0.82rem; }
.btn-discord {
  background: #5865f2;
  border-color: transparent;
  color: #fff;
}
.btn-discord:hover { background: #4752c4; }

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 3vw, 1.75rem);
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: start;
}
.timer-card { grid-row: span 2; }
.history-card { grid-column: 1 / -1; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .timer-card { grid-row: auto; }
}

.card {
  background: linear-gradient(180deg, var(--card), #0e1728);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.15rem, 2.4vw, 1.9rem);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.card-head h1 { font-size: 1.18rem; margin: 0; letter-spacing: 0.01em; }
.card-head h2 { font-size: 1.02rem; margin: 0; color: var(--text); }

.phase-badge {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.12);
  color: var(--focus);
}
.phase-badge[data-phase="short"] {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.12);
  color: var(--short);
}
.phase-badge[data-phase="long"] {
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.12);
  color: var(--long);
}

/* ---------- Ring ---------- */
.ring {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 1;
  margin: 0.25rem auto 0.75rem;
  display: grid;
  place-items: center;
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.ring-track { stroke: #1b2740; }
.ring-progress {
  stroke: var(--focus);
  stroke-dasharray: 615.75;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s ease;
}
.ring-progress[data-phase="short"] { stroke: var(--short); }
.ring-progress[data-phase="long"] { stroke: var(--long); }

.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.clock {
  font-size: clamp(2.6rem, 9vw, 3.9rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
}
.clock-sub { display: block; margin-top: 0.45rem; color: var(--text-soft); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- Alert ---------- */
.alert {
  margin: 0 0 0.9rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.14);
  border: 1px solid rgba(34, 211, 238, 0.45);
  color: #cffafe;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}
.alert[data-kind="short"], .alert[data-kind="long"] {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.45);
  color: #d1fae5;
}

/* ---------- Controls ---------- */
.cycle-dots { display: flex; justify-content: center; gap: 0.45rem; margin-bottom: 1rem; min-height: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #26344f; border: 1px solid #33456a; }
.dot[data-done="1"] { background: var(--accent); border-color: var(--accent); }

.controls { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.35rem; }

.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.7rem; }
.field label { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft); }
.field-row { display: flex; gap: 0.5rem; }
.field-row select { flex: 1; min-width: 0; }
.field-row .btn { flex: none; white-space: nowrap; }
select,
input[type="number"],
input[type="text"],
input:not([type]) {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  width: 100%;
}
select { cursor: pointer; }

.subject-form { display: flex; gap: 0.55rem; margin-bottom: 0.9rem; }
.subject-form input { flex: 1; min-width: 0; }

.settings { border-top: 1px solid var(--line); padding-top: 0.9rem; }
.settings summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-soft);
  list-style: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before { content: "▸ "; color: var(--accent); }
.settings[open] summary::before { content: "▾ "; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.9rem 0;
}
.settings-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.78rem; font-weight: 700; color: var(--text-soft); }
.switch { display: flex; align-items: center; gap: 0.55rem; font-size: 0.86rem; color: var(--text-soft); }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.hint {
  margin: 0.9rem 0 0;
  font-size: 0.86rem;
  color: var(--text-soft);
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
}

/* ---------- Stats ---------- */
.week-label { font-size: 0.78rem; color: var(--text-soft); }
.big-number { font-size: clamp(2rem, 5vw, 2.6rem); font-weight: 800; margin: 0.2rem 0 0.15rem; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-soft); font-size: 0.88rem; margin: 0; }

.bars { list-style: none; padding: 0; margin: 1.25rem 0 0; display: flex; flex-direction: column; gap: 0.8rem; }
.bar-row { display: grid; gap: 0.3rem; }
.bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; }
.bar-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { color: var(--text-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 9px; border-radius: 999px; background: #1b2740; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 4px; transition: width 0.35s ease; }

.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1.3rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.totals dt { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-soft); }
.totals dd { margin: 0.15rem 0 0; font-weight: 800; font-variant-numeric: tabular-nums; }

.empty { color: var(--text-soft); font-size: 0.88rem; margin: 1rem 0 0; }

/* ---------- History ---------- */
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.history li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: rgba(22, 33, 58, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.9rem;
}
.history-dot { width: 10px; height: 10px; border-radius: 50%; }
.history-subject { font-weight: 700; }
.history-date { color: var(--text-soft); font-size: 0.8rem; }
.history-duration { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 1.6rem 1rem 2rem;
  border-top: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 0.82rem;
}
.site-footer p { margin: 0.2rem 0; }
.site-footer .key { color: var(--text); font-weight: 800; letter-spacing: 0.06em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
