/* The time duration page: one form with three faces, a clock strip, and four readings of the same
   answer. Scoped to .time-page so nothing here can reach another calculator. Every colour, radius
   and border comes from the site tokens; both themes come for free. */

.time-page .time-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 14px;
}
.time-page .time-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.time-page .time-toggle { margin: 0; }
.time-page .time-toggle .chip { min-height: 40px; }
.time-page .time-toggle .chip[aria-pressed="true"] { border-color: var(--highlight); font-weight: 700; }
.time-page .time-check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.time-page .time-check input { width: 20px; height: 20px; accent-color: var(--primary); }
.time-page .time-options .hint { margin: 0; }

.time-page .mode-chips { margin: 0 0 16px; }
.time-page .mode-chips .chip { min-height: 44px; }
.time-page .mode-panel { margin-top: 2px; }

/* ---------------------------------------------------------------- The clock fields */

.time-page .time-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}
.time-page .clock-group {
  min-width: 0;
  margin: 0;
  padding: 8px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.time-page .clock-group legend {
  padding: 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.time-page .clock-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.time-page .clock-box {
  width: 58px;
  min-width: 0;
  min-height: 46px;
  padding: 6px 4px;
  text-align: center;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}
.time-page .clock-seconds { width: 52px; }
.time-page .clock-sep { font-weight: 700; font-size: 1.1rem; color: var(--muted); }
.time-page .clock-meridiem { min-height: 46px; width: auto; padding-inline: 8px; }

.time-page .duration-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.time-page .duration-field { min-width: 0; display: grid; gap: 4px; }
.time-page .duration-field label { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.time-page .duration-field input { width: 100%; min-width: 0; min-height: 42px; text-align: center; font-variant-numeric: tabular-nums; }

.time-page .time-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}
.time-page .time-actions .hint { margin: 0; flex: 1 1 220px; }

/* ---------------------------------------------------------------- The clock strip */

.time-page .time-timeline { margin: 4px 0 0; }
.time-page .time-timeline-ends {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.time-page .time-timeline-ends strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.time-page .time-timeline-ends > span:last-child { text-align: right; }
.time-page .time-track {
  position: relative;
  height: 30px;
  border-radius: 15px;
  background: var(--border);
  margin: 0 2px;
}
.time-page .time-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  min-width: 2px;
  border-radius: 15px;
  background: var(--primary);
  transition: width 0.25s ease, left 0.25s ease;
}
.time-page .time-mark {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--highlight);
}
.time-page .time-mark.is-start { background: var(--primary-dark); }
.time-page .time-mark.is-end { background: var(--highlight); }
.time-page .time-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.time-page .time-scale span { min-width: 0; }
.time-page .time-scale span:nth-child(2) { text-align: center; }
.time-page .time-scale span:last-child { text-align: right; }

/* ---------------------------------------------------------------- Four readings */

.time-page .time-conversions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.time-page .time-conversion {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent);
  border: 1px solid var(--border);
}
.time-page .time-conversion-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}
.time-page .time-conversion strong {
  display: block;
  font-size: clamp(1.15rem, 3.2vw, 1.45rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.time-page .time-conversion-note { display: block; font-size: 0.76rem; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- Break bars */

.time-page .time-bars { display: grid; gap: 10px; margin: 2px 0 0; }
.time-page .time-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
}
.time-page .time-bar-label { font-size: 0.86rem; font-weight: 600; grid-column: 1; grid-row: 1; }
.time-page .time-bar-row strong { grid-column: 2; grid-row: 1; font-variant-numeric: tabular-nums; }
.time-page .time-bar-track {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 12px;
  border-radius: 6px;
  background: var(--border);
  overflow: hidden;
}
.time-page .time-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: var(--primary);
  transition: width 0.25s ease;
}
.time-page .time-bar-fill.is-elapsed { background: var(--primary); }
.time-page .time-bar-fill.is-after { background: var(--highlight); }

/* ---------------------------------------------------------------- Every-day comparisons */

.time-page .time-comparisons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.time-page .time-comparison {
  min-width: 0;
  padding: 14px;
  border-radius: 12px;
  background: var(--accent);
  border: 1px solid var(--border);
}
.time-page .time-comparison-icon { display: block; font-size: 1.2rem; line-height: 1; margin-bottom: 8px; }
.time-page .time-comparison-value {
  display: block;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.time-page .time-comparison-label { display: block; font-size: 0.8rem; font-weight: 600; margin-top: 2px; }
.time-page .time-comparison-left { display: block; font-size: 0.74rem; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------------- The worked equation */

.time-page .time-equation {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent);
  border-inline-start: 3px solid var(--highlight);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- Signed contributions */

.time-page .time-contributions { display: grid; gap: 10px; margin-bottom: 10px; }
.time-page .time-contrib-row {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent);
  border: 1px solid var(--border);
}
.time-page .time-contrib-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.time-page .time-contrib-label { font-size: 0.86rem; font-weight: 600; overflow-wrap: anywhere; }
.time-page .time-contrib-value { font-size: 0.86rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.time-page .time-contrib-track {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  overflow: hidden;
}
.time-page .time-contrib-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: var(--primary);
  transition: width 0.25s ease;
}
.time-page .time-contrib-row.is-negative .time-contrib-fill { background: var(--highlight); }
.time-page .time-contrib-row.is-positive .time-contrib-fill { background: var(--primary); }
.time-page .time-share { display: block; font-size: 0.74rem; color: var(--muted); margin-top: 6px; }
.time-page .time-empty { font-size: 0.86rem; color: var(--muted); margin: 0; }

/* ---------------------------------------------------------------- Add-up rows */

.time-page .total-rows { display: grid; gap: 10px; margin: 4px 0 10px; }
.time-page .time-row {
  min-width: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.time-page .time-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.time-page .time-row-label {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  padding: 6px 10px;
  font-size: 0.9rem;
}
.time-page .total-remove {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.78rem;
  background: var(--accent);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.time-page .total-remove:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.time-page .total-remove:disabled,
.time-page .time-actions .btn-secondary:disabled { opacity: 0.5; cursor: default; }
.time-page .time-row-body {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.time-page .total-sign { margin: 0; flex: 0 0 auto; }
.time-page .total-sign .chip { min-width: 42px; min-height: 40px; justify-content: center; }
.time-page .total-sign .chip[aria-pressed="true"] { border-color: var(--highlight); font-weight: 700; }
.time-page .total-amounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex: 1 1 220px;
  min-width: 0;
}
.time-page .total-field { display: grid; gap: 3px; min-width: 0; }
.time-page .total-field span { font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.time-page .total-field input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 4px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.time-page .time-row.is-subtract { border-color: var(--highlight); }

/* ---------------------------------------------------------------- Small screens */

@media (max-width: 620px) {
  .time-page .time-fields,
  .time-page .time-options { grid-template-columns: minmax(0, 1fr); }
  .time-page .time-comparisons { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 430px) {
  .time-page .time-conversions { grid-template-columns: minmax(0, 1fr); }
  .time-page .clock-box { width: 52px; }
  .time-page .clock-seconds { width: 48px; }
  .time-page .duration-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .time-page .time-fill,
  .time-page .time-bar-fill,
  .time-page .time-contrib-fill { transition: none; }
}
