/* Pomodoro Timer — AUTH ONE
 * Design: minimalista, dark, vibe Apple, gradiente dourado/laranja.
 * Otimizado para TV em paisagem (16:9), fullscreen, sem scroll.
 */

/* ──────────────────────────────────────────────────────────
   Tokens
   ────────────────────────────────────────────────────────── */
:root {
  /* Cores — base */
  --bg-0:        #050505;
  --bg-1:        #0a0a0a;
  --bg-2:        #111111;
  --bg-elev:     rgba(255, 255, 255, 0.03);
  --bg-elev-2:   rgba(255, 255, 255, 0.06);

  /* Cores — texto (calibradas para TV: cinzas mais claros) */
  --text:        #ffffff;
  --text-soft:   rgba(255, 255, 255, 0.85);
  --text-mute:   rgba(255, 255, 255, 0.62);
  --text-dim:    rgba(255, 255, 255, 0.38);

  /* Bordas e linhas */
  --line:        rgba(255, 255, 255, 0.14);
  --line-soft:   rgba(255, 255, 255, 0.22);

  /* Acento — gradiente dourado/laranja */
  --accent-1:    #fde68a;
  --accent-2:    #f59e0b;
  --accent-3:    #ea580c;
  --accent-glow: rgba(245, 158, 11, 0.55);

  /* Cor neutra para fase de "interação" (mantém paleta monocromática) */
  --break:       rgba(255, 255, 255, 0.78);
  --break-glow:  rgba(255, 255, 255, 0.20);

  /* Tipografia */
  --font-sans: 'Helvetica Neue', 'Neue Haas Grotesk Display Pro', Helvetica,
               'Arimo', Arial, sans-serif;

  /* Pesos */
  --w-light:   300;
  --w-regular: 400;
  --w-medium:  500;
  --w-bold:    700;

  /* Espaçamentos baseados em viewport (escalam com o tamanho da TV) */
  --gap-xs:  0.5vw;
  --gap-sm:  1vw;
  --gap-md:  2vw;
  --gap-lg:  3vw;
  --gap-xl:  4vw;

  /* Raios — generosos, vibe Apple */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;

  /* Transições */
  --t-fast:   180ms cubic-bezier(0.22, 1, 0.36, 1);
  --t-mid:    320ms cubic-bezier(0.22, 1, 0.36, 1);
  --t-slow:   600ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: var(--w-light);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  user-select: none;
}

/* Modo TV: esconde cursor (ativado via ?tv=1 ou classe .app--tv) */
.app--tv,
.app--tv * {
  cursor: none !important;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ol, ul {
  list-style: none;
}

/* ──────────────────────────────────────────────────────────
   Background — textura sutil estilo referência
   ────────────────────────────────────────────────────────── */
.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(245, 158, 11, 0.04) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(234, 88, 12, 0.025) 0%, transparent 60%),
    var(--bg-0);
  overflow: hidden;
}

/* Grão sutil — adiciona profundidade à imagem da TV */
.app::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.025) 1px, transparent 0);
  background-size: 3px 3px;
  opacity: 0.6;
  z-index: 1;
}

.app > * {
  position: relative;
  z-index: 2;
}

/* ──────────────────────────────────────────────────────────
   Header — relógio · brand · data
   ────────────────────────────────────────────────────────── */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 2.4vh 3vw 0;
}

.clock {
  justify-self: start;
  font-size: 2.4vw;
  font-weight: var(--w-light);
  color: var(--text);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.brand {
  justify-self: center;
  display: flex;
  align-items: center;
}

.brand__logo {
  height: 2.6vh;
  width: auto;
  opacity: 0.92;
  filter: drop-shadow(0 0 24px rgba(255, 255, 255, 0.05));
}

.date {
  justify-self: end;
  font-size: 1.1vw;
  font-weight: var(--w-regular);
  color: var(--text-mute);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

/* ──────────────────────────────────────────────────────────
   Tabuleiro — 3 colunas
   ────────────────────────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  align-items: center;
  gap: var(--gap-lg);
  padding: 1vh 3vw;
  min-height: 0;
}

.board-side {
  display: flex;
  flex-direction: column;
  gap: 1.4vh;
  height: 100%;
  justify-content: center;
}

.board-side__label {
  font-size: 0.85vw;
  font-weight: var(--w-regular);
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding-left: 1.2vw;
  margin-bottom: 0.6vh;
}

.pomodoro-list {
  display: flex;
  flex-direction: column;
  gap: 0.9vh;
}

/* ──────────────────────────────────────────────────────────
   Cards de pomodoro
   ────────────────────────────────────────────────────────── */
.pomodoro-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1vw;
  padding: 1.4vh 1.4vw;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition:
    background var(--t-mid),
    border-color var(--t-mid),
    transform var(--t-mid),
    opacity var(--t-mid),
    box-shadow var(--t-mid);
}

.pomodoro-card__num {
  font-size: 1.3vw;
  font-weight: var(--w-light);
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  min-width: 1.6vw;
}

.pomodoro-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.2vh;
  min-width: 0;
}

.pomodoro-card__time {
  font-size: 1vw;
  font-weight: var(--w-regular);
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.pomodoro-card__hint {
  font-size: 0.72vw;
  font-weight: var(--w-regular);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  /* Espaço reservado para futura demanda (fase 2) */
  min-height: 0.9vw;
}

.pomodoro-card__status {
  width: 0.6vw;
  height: 0.6vw;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background var(--t-mid), box-shadow var(--t-mid), transform var(--t-mid);
}

/* Estado: futuro (default) — já estilizado acima */

/* Estado: concluído */
.pomodoro-card[data-state="done"] {
  opacity: 0.32;
}
.pomodoro-card[data-state="done"] .pomodoro-card__status {
  background: var(--text-mute);
}

/* Estado: foco ativo */
.pomodoro-card[data-state="focus"] {
  background: linear-gradient(135deg,
    rgba(245, 158, 11, 0.10),
    rgba(234, 88, 12, 0.04));
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.20),
    0 8px 32px -12px rgba(245, 158, 11, 0.40);
  transform: translateX(0.4vw);
}
.pomodoro-card[data-state="focus"] .pomodoro-card__num {
  color: var(--accent-2);
  font-weight: var(--w-medium);
}
.pomodoro-card[data-state="focus"] .pomodoro-card__time {
  color: var(--text);
}
.pomodoro-card[data-state="focus"] .pomodoro-card__status {
  background: var(--accent-2);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: scale(1.4);
}

/* Estado: interação ativa */
.pomodoro-card[data-state="break"] {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 8px 32px -12px rgba(255, 255, 255, 0.20);
}
.pomodoro-card[data-state="break"] .pomodoro-card__num,
.pomodoro-card[data-state="break"] .pomodoro-card__time {
  color: var(--text);
}
.pomodoro-card[data-state="break"] .pomodoro-card__hint {
  color: var(--text-soft);
}
.pomodoro-card[data-state="break"] .pomodoro-card__status {
  background: var(--text);
  box-shadow: 0 0 12px var(--break-glow);
  transform: scale(1.4);
}

/* ──────────────────────────────────────────────────────────
   Timer central — anel circular
   ────────────────────────────────────────────────────────── */
.board-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer {
  position: relative;
  width: min(54vh, 32vw);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.timer__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 4;
}

.timer__progress {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 5;
  stroke-linecap: round;
  /* circumference = 2π × 148 ≈ 929.91 */
  stroke-dasharray: 929.91;
  stroke-dashoffset: 929.91;
  transition: stroke-dashoffset var(--t-mid);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.timer__dot {
  fill: var(--accent-1);
  transition: opacity var(--t-mid);
}

.timer__dot-glow {
  fill: var(--accent-2);
  opacity: 0.7;
  transition: opacity var(--t-mid);
}

/* No estado break, anel e dot ficam brancos */
.timer[data-phase="break"] .timer__progress {
  stroke: var(--text);
  filter: drop-shadow(0 0 8px var(--break-glow));
}
.timer[data-phase="break"] .timer__dot {
  fill: var(--text);
}
.timer[data-phase="break"] .timer__dot-glow {
  fill: var(--text);
  opacity: 0.5;
}

/* No estado off/setup, esconde dot */
.timer[data-phase="off"] .timer__dot,
.timer[data-phase="off"] .timer__dot-glow,
.timer[data-phase="setup"] .timer__dot,
.timer[data-phase="setup"] .timer__dot-glow {
  opacity: 0;
}

.timer__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8vh;
  text-align: center;
}

.timer__label {
  font-size: 0.95vw;
  font-weight: var(--w-regular);
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.22em;
}

.timer__time {
  font-size: 7.5vw;
  font-weight: var(--w-light);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-shadow: 0 0 80px rgba(245, 158, 11, 0.10);
  margin: 0.3vh 0;
}

.timer__phase {
  font-size: 1.05vw;
  font-weight: var(--w-medium);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--accent-2);
}
.timer[data-phase="break"] .timer__phase  { color: var(--text); }
.timer[data-phase="lunch"] .timer__phase  { color: var(--text-soft); }
.timer[data-phase="setup"] .timer__phase  { color: var(--text-mute); }
.timer[data-phase="off"]   .timer__phase  { color: var(--text-mute); }

.timer__range {
  font-size: 0.9vw;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  margin-top: 0.4vh;
}

/* ──────────────────────────────────────────────────────────
   Footer — barra de progresso do dia + toggle som
   ────────────────────────────────────────────────────────── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
  padding: 0 3vw 2.4vh;
}

.day-progress {
  display: flex;
  align-items: center;
  gap: 1.4vw;
  flex: 1;
  max-width: 60vw;
}

.day-progress__bar {
  position: relative;
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.day-progress__fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-3));
  border-radius: 999px;
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width var(--t-slow);
}

.day-progress__text {
  font-size: 0.85vw;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Toggle de som */
.sound-toggle {
  width: 2.6vw;
  height: 2.6vw;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.sound-toggle:hover {
  background: var(--bg-elev-2);
  border-color: var(--line-soft);
  transform: scale(1.05);
}
.sound-toggle__icon {
  width: 55%;
  height: 55%;
  fill: var(--text-soft);
}
.sound-toggle__icon--off { display: none; }
.sound-toggle[data-muted="true"] .sound-toggle__icon       { display: none; }
.sound-toggle[data-muted="true"] .sound-toggle__icon--off  { display: block; }

/* ──────────────────────────────────────────────────────────
   Status badge — canto inferior esquerdo
   ────────────────────────────────────────────────────────── */
.status-badge {
  position: absolute;
  bottom: 2.4vh;
  left: 3vw;
  font-size: 0.7vw;
  font-weight: var(--w-medium);
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  pointer-events: none;
  display: none; /* exibido apenas em estados especiais */
}

/* Demo badge — indicador discreto de modo demo */
.demo-badge {
  position: absolute;
  bottom: 2.4vh;
  right: 3vw;
  transform: translateX(-3.6vw); /* fica à esquerda do botão de som */
  z-index: 20;
  padding: 0.6vh 1vw;
  font-size: 0.72vw;
  font-weight: var(--w-bold);
  letter-spacing: 0.28em;
  color: var(--accent-1);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 999px;
  text-transform: uppercase;
  animation: demoPulse 2s ease-in-out infinite;
  pointer-events: none;
}
.demo-badge[hidden] { display: none; }

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

/* ──────────────────────────────────────────────────────────
   Overlay de almoço
   ────────────────────────────────────────────────────────── */
.lunch-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: fadeIn var(--t-slow) both;
}

.lunch-overlay[hidden] { display: none; }

.lunch-overlay__content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vh;
}

.lunch-overlay__eyebrow {
  font-size: 0.95vw;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-variant-numeric: tabular-nums;
}

.lunch-overlay__title {
  font-size: 11vw;
  font-weight: var(--w-light);
  letter-spacing: -0.04em;
  line-height: 0.95;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lunch-overlay__sub {
  font-size: 1.6vw;
  color: var(--text-soft);
  font-weight: var(--w-light);
  letter-spacing: 0.04em;
}

.lunch-overlay__remaining {
  margin-top: 2vh;
  font-size: 1.1vw;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: scale(1); }
}

/* ──────────────────────────────────────────────────────────
   Pulse sutil no card ativo (chama atenção sem irritar)
   ────────────────────────────────────────────────────────── */
@keyframes activePulse {
  0%, 100% { box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.20),
    0 8px 32px -12px rgba(245, 158, 11, 0.40); }
  50%      { box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.32),
    0 8px 40px -10px rgba(245, 158, 11, 0.55); }
}

.pomodoro-card[data-state="focus"] {
  animation: activePulse 4s ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────
   10 segundos finais do foco — celebração visual
   ────────────────────────────────────────────────────────── */
@keyframes finishPulse {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 0 80px rgba(245, 158, 11, 0.10);
  }
  50% {
    transform: scale(1.06);
    text-shadow:
      0 0 60px rgba(245, 158, 11, 0.50),
      0 0 120px rgba(234, 88, 12, 0.30);
  }
}

@keyframes finishRingGlow {
  0%, 100% { filter: drop-shadow(0 0 8px var(--accent-glow)); }
  50%      { filter: drop-shadow(0 0 24px rgba(245, 158, 11, 0.95))
                     drop-shadow(0 0 48px rgba(234, 88, 12, 0.6)); }
}

.timer--finishing .timer__time {
  animation: finishPulse 1s ease-in-out infinite;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.timer--finishing .timer__progress {
  animation: finishRingGlow 1s ease-in-out infinite;
}

.timer--finishing .timer__phase {
  letter-spacing: 0.4em;
}

/* ──────────────────────────────────────────────────────────
   Spotify widget (Task 7 — placeholder, será implementado depois)
   ────────────────────────────────────────────────────────── */
.spotify-widget {
  position: absolute;
  bottom: 6vh;
  right: 3vw;
  display: none;
}

/* ──────────────────────────────────────────────────────────
   Acessibilidade: respeitar redução de movimento
   ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
