/* === SLEEP DEBT CALCULATOR === */

.page-header { margin-bottom: 28px; }

.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 24px;
}

/* Target row */
.target-row {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.row-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.row-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
}

.row-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Slider — uses native range styling for consistency */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--green-light);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-dark);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.slider::-webkit-slider-thumb:hover { background: var(--green-mid); transform: scale(1.08); }

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-dark);
  border: 3px solid var(--surface);
  cursor: pointer;
}

.slider:focus { background: #DBEED6; }

.slider-target { background: linear-gradient(90deg, var(--green-light), var(--green-mid)); }

/* Days */
.days-head {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.days-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.day-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.day-row {
  display: grid;
  grid-template-columns: 80px 1fr 70px;
  align-items: center;
  gap: 10px;
}

.day-name {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.day-val {
  font-size: 0.95rem;
  text-align: right;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.day-row.touched .day-name { color: var(--green-dark); }
.day-row.touched .day-val { color: var(--green-dark); }

/* Actions */
.calc-actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Result */
.result {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px 24px 24px;
  margin: 24px 0 40px;
  text-align: center;
}

.result[hidden] { display: none; }

.result-band {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 22px;
  border-radius: 14px;
  margin-bottom: 14px;
  background: var(--green-light);
}

.result-score {
  font-size: 3rem;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.result-of {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.result-category {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}

.result.cat-none     .result-band  { background: #DDEFD8; }
.result.cat-none     .result-score,
.result.cat-none     .result-category { color: #2E6B30; }

.result.cat-mild     .result-band  { background: #FBF2C8; }
.result.cat-mild     .result-score,
.result.cat-mild     .result-category { color: #8A6914; }

.result.cat-moderate .result-band  { background: #FAE0C0; }
.result.cat-moderate .result-score,
.result.cat-moderate .result-category { color: #B35A1F; }

.result.cat-severe   .result-band  { background: #F8D6D2; }
.result.cat-severe   .result-score,
.result.cat-severe   .result-category { color: #A82828; }

/* Chart */
.chart-wrap {
  margin: 18px auto 18px;
  max-width: 480px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 6px;
  height: 140px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.bar-fill {
  width: 22px;
  border-radius: 4px 4px 0 0;
  transition: height 0.6s ease;
  background: var(--green-mid);
  min-height: 2px;
}

.bar-fill.deficit { background: #D87878; }
.bar-fill.met     { background: var(--green-mid); }
.bar-fill.surplus { background: #6AA1C8; }

.bar-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-item { display: inline-flex; align-items: center; gap: 5px; }

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.sw-deficit { background: #D87878; }
.sw-met     { background: var(--green-mid); }
.sw-surplus { background: #6AA1C8; }

/* Result text blocks */
.result-interp {
  font-size: 0.97rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 560px;
  margin: 0 auto 12px;
  text-align: left;
}

.result-recovery {
  background: var(--green-light);
  border-left: 3px solid var(--green-mid);
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--text-muted);
  text-align: left;
  margin: 0 auto 12px;
  line-height: 1.55;
  max-width: 560px;
}

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

.disclaimer {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

/* Info section */
.info-section h2 { margin-top: 32px; }

.info-section a {
  color: var(--green-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.info-section a:hover { color: var(--green-mid); }

.info-section code {
  background: var(--green-light);
  color: var(--green-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (max-width: 580px) {
  /* Stack the slider on its own row so it gets the full width
     of the container — much easier to hit accurately on touch. */
  .day-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name val"
      "slider slider";
    gap: 4px 10px;
  }
  .day-name { grid-area: name; }
  .day-val  { grid-area: val; }
  .day-row .slider-day { grid-area: slider; width: 100%; }
}

@media (max-width: 540px) {
  .chart { height: 110px; }
  .bar-fill { width: 18px; }
  .bar-name { font-size: 0.68rem; }
}

@media (max-width: 480px) {
  .calc { padding: 16px; }
}
