/* operatori-risorse-timer.css — Big Timer countdown
   Riusa pattern .op-page-hero / .op-section / .hd-btn da operatori.css + editorial.css.
   Mobile-first. Dark mode via [data-theme="dark"].
*/

/* ── Stage timer ──────────────────────────────────────────── */

.tm-stage {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
  border-radius: 16px;
  padding: 32px 16px;
  text-align: center;
  margin-bottom: 24px;
  transition:
    background 0.3s,
    color 0.3s;
}

.tm-stage[data-state='running'] {
  background: var(--color-bg-warm, #f5e9d8);
}

.tm-stage[data-state='ended'] {
  background: #c04428;
  color: #fff;
  animation: tmFlash 0.5s ease-in-out 6;
}

@keyframes tmFlash {
  0%,
  100% {
    background: #c04428;
  }
  50% {
    background: #8a2f1d;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tm-stage[data-state='ended'] {
    animation: none;
  }
}

.tm-current-label {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tm-stage[data-state='ended'] .tm-current-label,
.tm-stage[data-state='running'] .tm-current-label {
  color: inherit;
}

.tm-display {
  display: block;
  margin: 16px 0;
}

.tm-time {
  font-family: var(--font-heading, 'Fraunces', serif);
  font-size: clamp(72px, 22vw, 240px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
  color: inherit;
}

.tm-progress {
  margin: 16px auto 0;
  max-width: 600px;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.tm-progress-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--color-primary, #c04428);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.2s linear;
}

.tm-stage[data-state='ended'] .tm-progress {
  display: none;
}

.tm-queue-info {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.95em;
  color: var(--color-text-muted, #666);
}

.tm-stage[data-state='running'] .tm-queue-info,
.tm-stage[data-state='ended'] .tm-queue-info {
  color: inherit;
  opacity: 0.85;
}

.tm-queue-step {
  font-weight: 600;
}

/* ── Controlli ──────────────────────────────────────────── */

.tm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
}

.tm-btn-primary {
  min-width: 140px;
}

@media (max-width: 480px) {
  .tm-controls .hd-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 12px 8px;
    font-size: 0.92em;
  }
  .tm-btn-primary {
    flex-basis: 100%;
  }
}

/* ── Coda ──────────────────────────────────────────── */

.tm-queue-section {
  background: var(--color-bg-warm, #f9f4ec);
}

[data-theme='dark'] .tm-queue-section {
  background: rgba(255, 255, 255, 0.03);
}

.tm-queue-lead {
  margin: 0 0 16px;
  color: var(--color-text-muted, #555);
}

.tm-queue-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  gap: 8px;
}

.tm-queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
  border-radius: 8px;
  transition: opacity 0.2s;
}

.tm-queue-item.is-current {
  border-color: var(--color-primary, #c04428);
  border-width: 2px;
  background: var(--color-bg-warm, #fdf6ed);
}

.tm-queue-item.is-done {
  opacity: 0.5;
}

.tm-queue-item-handle {
  cursor: grab;
  user-select: none;
  font-size: 1.2em;
  color: var(--color-text-muted, #999);
  padding: 0 4px;
}

.tm-queue-item-handle:active {
  cursor: grabbing;
}

.tm-queue-item.is-dragging {
  opacity: 0.4;
}

.tm-queue-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-queue-item-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-text-muted, #666);
  white-space: nowrap;
}

.tm-queue-item-remove {
  background: transparent;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.85em;
  color: var(--color-text-muted, #666);
  min-width: 32px;
  min-height: 32px;
}

.tm-queue-item-remove:hover {
  background: rgba(192, 68, 40, 0.1);
  color: var(--color-primary, #c04428);
  border-color: var(--color-primary, #c04428);
}

/* ── Add form ──────────────────────────────────────────── */

.tm-queue-add {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
  padding: 16px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
  border-radius: 8px;
  margin-bottom: 24px;
}

.tm-queue-add-label {
  font-size: 0.85em;
  font-weight: 500;
  color: var(--color-text-muted, #666);
  margin-top: 4px;
}

.tm-queue-add input[type='text'],
.tm-queue-add input[type='number'] {
  padding: 10px 12px;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1em;
}

.tm-queue-add input[type='number'] {
  max-width: 100px;
}

@media (min-width: 720px) {
  .tm-queue-add {
    grid-template-columns: auto 1fr auto auto auto auto auto;
  }
  .tm-queue-add-label {
    margin-top: 0;
  }
}

/* ── Presets ──────────────────────────────────────────── */

.tm-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tm-presets-label {
  font-size: 0.9em;
  color: var(--color-text-muted, #666);
  margin-right: 4px;
}

.tm-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
  border-radius: 999px;
  background: var(--color-bg-card);
  color: var(--color-text);
  font-size: 0.9em;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.tm-preset-chip:hover,
.tm-preset-chip:focus-visible {
  background: rgba(192, 68, 40, 0.08);
  border-color: var(--color-primary, #c04428);
}

.tm-preset-time {
  color: var(--color-text-muted, #777);
  font-size: 0.85em;
}

/* ── Opzioni ──────────────────────────────────────────── */

.tm-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 600px) {
  .tm-options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.tm-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
}

.tm-option:hover {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme='dark'] .tm-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tm-option input[type='checkbox'] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* ── Share ──────────────────────────────────────────── */

.tm-share {
  padding: 16px;
  background: var(--color-bg-card);
  border-radius: 8px;
}

.tm-share h3 {
  margin: 0 0 8px;
  font-size: 1.1em;
}

.tm-share-lead {
  margin: 0 0 12px;
  font-size: 0.92em;
  color: var(--color-text-muted, #666);
}

.tm-share-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tm-share-row input[type='text'] {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
  border-radius: 6px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono, monospace);
  font-size: 0.85em;
}

.tm-share-msg {
  margin: 8px 0 0;
  font-size: 0.9em;
  color: var(--color-success, #2d7a3a);
}

/* ── Fullscreen ──────────────────────────────────────────── */

.tm-stage:fullscreen,
.tm-stage:-webkit-full-screen {
  background: var(--color-bg);
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  margin: 0;
}

.tm-stage:fullscreen .tm-time {
  font-size: clamp(120px, 30vw, 480px);
}

.tm-stage:fullscreen[data-state='ended'] {
  background: #c04428;
  color: #fff;
}

/* ── Print ──────────────────────────────────────────── */

@media print {
  .tm-controls,
  .tm-queue-add,
  .tm-presets,
  .tm-options-section,
  .tm-share {
    display: none;
  }
  .tm-stage {
    page-break-after: avoid;
  }
}
