/* ============================================
   Pomodoro Timer — styles.css
   Builds on design/design-system.css tokens
   (--color-*, --font-*, --space-*, --radius-* etc.)
   with local fallbacks in case a token is absent.
   ============================================ */

:root {
  --pt-bg: var(--color-bg, #faf6f0);
  --pt-surface: var(--color-surface, #ffffff);
  --pt-text: var(--color-text, #2b2420);
  --pt-text-muted: var(--color-text-muted, #6b6058);
  --pt-accent: var(--color-primary, #d96c4a);
  --pt-accent-contrast: var(--color-primary-contrast, #ffffff);
  --pt-border: var(--color-border, #e6ddd3);
  --pt-break: var(--color-secondary, #4a8d7c);
  --pt-radius: var(--radius-lg, 20px);
  --pt-radius-sm: var(--radius-sm, 10px);
  --pt-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.08));
  --pt-font-display: var(--font-display, 'Fraunces', serif);
  --pt-font-body: var(--font-body, system-ui, sans-serif);
  --pt-transition: 0.25s ease;
}

* {
  box-sizing: border-box;
}

html[data-theme="dark"] {
  --pt-bg: var(--color-bg-dark, #1b1714);
  --pt-surface: var(--color-surface-dark, #262019);
  --pt-text: var(--color-text-dark, #f3ece3);
  --pt-text-muted: var(--color-text-muted-dark, #b8ac9f);
  --pt-accent: var(--color-primary-dark, #e8825c);
  --pt-border: var(--color-border-dark, #3a322a);
  --pt-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--pt-bg);
  color: var(--pt-text);
  font-family: var(--pt-font-body);
  transition: background-color var(--pt-transition), color var(--pt-transition);
}

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.app-title {
  font-family: var(--pt-font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--pt-text);
}

.theme-toggle {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--pt-transition), background-color var(--pt-transition);
}

.theme-toggle:hover {
  transform: scale(1.05);
}

.theme-toggle:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--pt-accent);
  outline-offset: 2px;
}

/* ===== Timer Card ===== */
.timer-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  transition: background-color var(--pt-transition), border-color var(--pt-transition);
}

.session-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pt-accent);
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--pt-accent);
  border-radius: 999px;
}

/* ===== Progress Ring ===== */
.ring-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
  height: 280px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--pt-border);
  stroke-width: 14;
}

.ring-fg {
  fill: none;
  stroke: var(--pt-accent);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 754;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke var(--pt-transition);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
}

.time-display {
  font-family: var(--pt-font-display);
  font-size: 3rem;
  font-weight: 600;
  line-height: 1;
  color: var(--pt-text);
}

.status-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pt-text-muted);
}

/* break mode tint handled via JS toggling class on ring-fg? keep CSS fallback */
.ring-fg.break-mode {
  stroke: var(--pt-break);
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font-family: var(--pt-font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.4rem;
  border-radius: var(--pt-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--pt-transition), transform var(--pt-transition), opacity var(--pt-transition);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--pt-accent);
  color: var(--pt-accent-contrast);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-secondary {
  background: transparent;
  color: var(--pt-text);
  border-color: var(--pt-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--pt-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--pt-text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--pt-text);
  background: var(--pt-bg);
}

.btn-small {
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
}

.session-counter {
  font-size: 0.9rem;
  color: var(--pt-text-muted);
}

.session-counter span {
  font-weight: 700;
  color: var(--pt-text);
}

/* ===== History ===== */
.history-card {
  background: var(--pt-surface);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
  padding: 1.5rem;
  transition: background-color var(--pt-transition), border-color var(--pt-transition);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-header h2 {
  font-family: var(--pt-font-display);
  font-size: 1.1rem;
  margin: 0;
  color: var(--pt-text);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius-sm);
  font-size: 0.9rem;
  background: var(--pt-bg);
  color: var(--pt-text);
}

.history-empty {
  justify-content: center;
  color: var(--pt-text-muted);
  font-style: italic;
  border-style: dashed;
}

/* ===== Notification ===== */
.notification {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 20px);
  background: var(--pt-surface);
  color: var(--pt-text);
  border: 1px solid var(--pt-border);
  box-shadow: var(--pt-shadow);
  padding: 0.85rem 1.25rem;
  border-radius: var(--pt-radius-sm);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--pt-transition), transform var(--pt-transition);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.notification.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .ring-wrap {
    width: 220px;
    height: 220px;
  }

  .time-display {
    font-size: 2.2rem;
  }

  .app-title {
    font-size: 1.2rem;
  }

  .controls {
    gap: 0.5rem;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 360px) {
  .controls {
    flex-direction: column;
    width: 100%;
  }

  .controls .btn {
    width: 100%;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .ring-fg {
    transition: none;
  }
}