/* Programmable interval timer */

.timer {
  max-width: 720px;
  margin: 0 auto;
}

.timer__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: 0 2px 12px rgba(17, 17, 17, 0.04);
  margin: 1.5rem 0 2rem;
}

/* Interval list */

.timer__intervals {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timer__interval {
  display: grid;
  grid-template-columns: 1fr 100px 100px auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.timer__interval:hover {
  border-color: #c8c8d0;
}

.timer__interval--work {
  border-left: 4px solid var(--brand);
}

.timer__interval--rest {
  border-left: 4px solid #f0ad4e;
}

.timer__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.timer__field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.timer__field input,
.timer__field select {
  font-family: "Inter", sans-serif;
  font-size: 0.9375rem;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.timer__field input:focus,
.timer__field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 209, 163, 0.18);
}

.timer__field input[type="number"] {
  -moz-appearance: textfield;
  width: 100%;
}

.timer__field input::-webkit-outer-spin-button,
.timer__field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.timer__remove {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  align-self: end;
  margin-bottom: 0.25rem;
}

.timer__remove:hover {
  color: #e04848;
  background: rgba(224, 72, 72, 0.08);
}

/* Add buttons */

.timer__add-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.timer__add {
  appearance: none;
  background: #fff;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex: 1;
}

.timer__add:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: rgba(0, 209, 163, 0.04);
}

.timer__add--work:hover {
  border-color: var(--brand);
}

.timer__add--rest:hover {
  border-color: #f0ad4e;
  color: #c48a00;
}

/* Rounds and countdown */

.timer__settings {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.timer__settings .timer__field {
  min-width: 100px;
}

/* Total summary */

.timer__summary {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 209, 163, 0.06);
  border-radius: 10px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.timer__summary strong {
  color: var(--text);
}

/* Display area */

.timer__display {
  margin-top: 1.5rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 1.5px solid rgba(0, 209, 163, 0.25);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0, 209, 163, 0.04), rgba(0, 209, 163, 0.10));
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.3s, border-color 0.3s;
}

.timer__display--work {
  background: linear-gradient(180deg, rgba(0, 209, 163, 0.06), rgba(0, 209, 163, 0.15));
  border-color: var(--brand);
}

.timer__display--rest {
  background: linear-gradient(180deg, rgba(240, 173, 78, 0.06), rgba(240, 173, 78, 0.15));
  border-color: #f0ad4e;
}

.timer__display--countdown {
  background: linear-gradient(180deg, rgba(100, 100, 120, 0.06), rgba(100, 100, 120, 0.15));
  border-color: #999;
}

.timer__display--done {
  background: linear-gradient(180deg, rgba(0, 209, 163, 0.08), rgba(0, 209, 163, 0.20));
  border-color: var(--brand);
}

.timer__phase-label {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.timer__interval-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.timer__countdown {
  font-size: 5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.timer__display--rest .timer__countdown {
  color: #c48a00;
}

.timer__display--countdown .timer__countdown {
  color: var(--text-secondary);
}

.timer__round-info {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.timer__idle-msg {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Controls */

.timer__controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  justify-content: center;
}

.timer__btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 2rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.timer__btn--start {
  background: var(--brand);
  color: #fff;
}

.timer__btn--start:hover {
  background: var(--brand-dark);
}

.timer__btn--pause {
  background: #f0ad4e;
  color: #fff;
}

.timer__btn--pause:hover {
  background: #d9952a;
}

.timer__btn--reset {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.timer__btn--reset:hover {
  background: #f5f5f7;
}

.timer__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Progress bar */

.timer__progress-wrap {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.timer__progress {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.timer__display--rest .timer__progress {
  background: #f0ad4e;
}

/* Timeline preview */

.timer__timeline {
  display: flex;
  gap: 2px;
  margin-top: 1rem;
  border-radius: 6px;
  overflow: hidden;
  height: 8px;
}

.timer__timeline-seg {
  height: 100%;
  transition: opacity 0.2s;
}

.timer__timeline-seg--work {
  background: var(--brand);
}

.timer__timeline-seg--rest {
  background: #f0ad4e;
}

.timer__timeline-seg--active {
  opacity: 1;
}

.timer__timeline-seg--done {
  opacity: 0.35;
}

.timer__timeline-seg--upcoming {
  opacity: 0.6;
}

/* Responsive */

@media (max-width: 600px) {
  .timer__card {
    padding: 1.25rem 1rem 1rem;
    border-radius: 12px;
  }

  .timer__interval {
    grid-template-columns: 1fr 80px 80px auto;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
  }

  .timer__field input,
  .timer__field select {
    padding: 0.5rem 0.6rem;
    font-size: 0.875rem;
  }

  .timer__countdown {
    font-size: 3.5rem;
  }

  .timer__display {
    padding: 2rem 1rem;
    min-height: 160px;
  }

  .timer__settings {
    gap: 1rem;
  }
}

@media (max-width: 420px) {
  .timer__interval {
    grid-template-columns: 1fr 1fr auto;
    gap: 0.5rem;
  }

  .timer__interval .timer__field:first-child {
    grid-column: 1 / -2;
  }
}
