/* Sleep Tools — tool.css
   Extra styles for tool pages. Load it after site.css. Colours, fonts,
   buttons, tags, cards, the step layout and the questions grid all come
   from site.css; this file only adds what a tool page needs on top. */

/* Parts of a tool stay hidden until the step before them is done. Without
   this line, display:flex on a block would un-hide it. */
[hidden] { display: none !important; }

/* ── Motion ─────────────────────────────────────────────────────
   Nothing at the top of the page animates on load. Motion starts when
   the visitor does something. class="rise": a block slides up into
   place when it appears. Set --wait on it to make it follow the one
   before. All of it is switched off at the bottom of this file for
   people who ask their device for less motion. */
.rise { animation: rise .5s cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: var(--wait, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } }

/* Buttons give a little when pressed */
.cue, .button { transition: transform .1s, background-color .15s; }
.cue:active:not(:disabled), button.button:active { transform: scale(.96); }

/* ── Pieces only tool pages use ───────────────────────────────
   habit-tools keeps these in site.css. Here the home page doesn't use
   them, so they live in this file. */

/* The step number. Same size as the time of day (.step-time) on the home page. */
.step-num { font-family: "Big Shoulders Display", "Arial Narrow", sans-serif; font-size: 4.5rem; font-weight: 900; line-height: .8; color: var(--moon); }

/* The note: one sentence on a moon-yellow slip, a little crooked */
.sticky-sentence {
  margin-top: 26px;
  padding: 24px 22px 26px;
  background: var(--moon);
  color: var(--ink);
  transform: rotate(-1.2deg);
  font-family: var(--display);
  font-size: clamp(1.875rem, 3vw, 2.625rem);
  font-weight: 800;
  line-height: 1;
}

/* A short list of times. The row with class "on" is the chosen one. */
.plan { width: 100%; margin-top: 18px; border-collapse: collapse; }
.plan th, .plan td { padding: 10px 0; border-top: 2px dashed var(--line); text-align: left; }
.plan th { font-weight: 800; }
.plan td { text-align: right; color: var(--muted); }
.plan tr.on th, .plan tr.on td { color: var(--moon); }

/* ── Top of a tool page: title on the left, step 1 on the right ── */

.tool-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 40px 72px;
  padding-block: clamp(24px, 4vw, 48px) clamp(64px, 8vw, 96px);
}
.tool-intro { flex: 1 1 400px; min-width: 0; }
.tool-card { flex: 1 1 440px; min-width: 0; }

.crumbs { margin-bottom: 26px; font-size: .875rem; font-weight: 600; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs span { margin-inline: 6px; }

.tool-intro h1 {
  margin-top: 16px;
  font-family: var(--display);
  font-size: clamp(3.75rem, 7.4vw, 7.5rem);
  font-weight: 900;
  line-height: .86;
  text-wrap: balance;
}
.tool-intro .lede { margin-top: 24px; max-width: 520px; }
.tool-note { margin-top: 16px; max-width: 520px; font-size: .9375rem; color: var(--muted); }

/* ── Step 1 card ────────────────────────────────────────────── */

.tool-kicker { font-size: .875rem; font-weight: 800; color: var(--moon); }
.tool-q {
  margin-top: 6px;
  font-family: var(--display);
  font-size: clamp(2rem, 3.2vw, 2.75rem);
  font-weight: 900;
  line-height: .95;
}

/* A clock time or a number, written large */
.time-fields { display: flex; gap: 14px; margin-top: 22px; }
.time-field { flex: 1 1 0; min-width: 0; }
.time-field label { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 700; color: var(--muted); }
.time-field input {
  width: 100%;
  height: 96px;
  padding: 0 16px;
  border: 2px solid var(--text);
  border-radius: 0;
  background: var(--night);
  color: var(--text);
  font-family: "Big Shoulders Display", "Arial Narrow", sans-serif;
  font-size: 4.5rem;
  font-weight: 900;
  line-height: 1;
}
.time-field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.time-field input::-webkit-outer-spin-button,
.time-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-field input::placeholder { color: var(--line); opacity: 1; }
.time-field input:focus-visible { outline: 3px solid var(--moon); outline-offset: 2px; }

/* A plain, smaller field */
.plain-field { margin-top: 18px; }
.plain-field label { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 700; color: var(--muted); }
.plain-field input {
  width: 100%;
  height: 56px;
  padding: 0 14px;
  border: 2px solid var(--text);
  border-radius: 0;
  background: var(--night);
  color: var(--text);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 700;
}
.plain-field input:focus-visible { outline: 3px solid var(--moon); outline-offset: 2px; }

/* Sleep debt: one row per night, hours and minutes side by side */
.night-rows { list-style: none; margin-top: 10px; }
.night-rows li { display: flex; align-items: center; gap: 10px; padding-block: 8px; border-top: 2px dashed var(--line); }
.night-rows li > span:first-child { flex: 1 1 auto; font-weight: 700; }
.night-rows input {
  width: 68px;
  height: 48px;
  padding: 0 10px;
  border: 2px solid var(--text);
  border-radius: 0;
  background: var(--night);
  color: var(--text);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  text-align: right;
}
.night-rows input:focus-visible { outline: 3px solid var(--moon); outline-offset: 2px; }
.night-rows .unit { color: var(--muted); font-size: .875rem; font-weight: 700; }

.tool-card .card-label { margin-top: 22px; }
.tool-card .cues { margin-top: 10px; }
.tool-card .button { margin-top: 26px; width: 100%; justify-content: center; }
.cue:disabled { border-color: var(--line); color: var(--muted); opacity: .6; cursor: not-allowed; }

.tool-error { margin-top: 16px; padding: 10px 14px; border-left: 4px solid var(--moon); background: var(--night); font-weight: 700; }

/* ── Result band (lighter blue, like the spotlight band at home) ── */

.tool-result { background: var(--panel); padding-block: 72px 40px; scroll-margin-top: 0; }
.tool-result:focus { outline: none; }
.tool-result .card { background: var(--night); box-shadow: none; }

/* Wide screens: the answer and the numbers on the left, the card on the
   right. Narrow screens: the answer, then the card, then the numbers. */
.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top side" "stats side";
  column-gap: 72px;
  padding-bottom: 72px;
}
.result-top { grid-area: top; }
.result-side { grid-area: side; align-self: center; }
.result-stats { grid-area: stats; }
@media (max-width: 960px) {
  .result-row { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "top" "side" "stats"; row-gap: 32px; }
  .result-stats .stats { margin-top: 0; }
}

.big-number {
  margin-top: 22px;
  font-family: "Big Shoulders Display", "Arial Narrow", sans-serif;
  font-size: clamp(6rem, 13vw, 12.5rem);
  font-weight: 900;
  line-height: .8;
  color: var(--moon);
  font-variant-numeric: tabular-nums;
}
/* A clock time or a duration: "10:45 PM", "5h 15m", with the letters small */
.big-time { font-size: clamp(4.75rem, 9.5vw, 9.5rem); line-height: .85; }
.big-time small { margin-left: .06em; font-size: .36em; color: var(--text); }

.big-unit { margin-top: 12px; font-family: var(--display); font-size: clamp(2rem, 3.6vw, 3.25rem); font-weight: 900; line-height: 1; }
.result-line { margin-top: 20px; max-width: 520px; font-size: 1.1875rem; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 26px 0 0; max-width: 520px; }
.stats > div { padding-block: 12px; border-top: 2px solid var(--text); }
.stats dt { font-size: .875rem; font-weight: 700; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-family: var(--display); font-size: 1.875rem; font-weight: 800; line-height: 1.1; }

/* Bars that compare a few values. A row with class "on" stands out. */
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin-top: 18px; font-size: .9375rem; }
.bar-row p:first-child span { color: var(--muted); }
.bar-row p + p { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 26px; border: 2px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--text); transform-origin: left; animation: grow .8s ease-out backwards; }
.bar-row.on .bar i { background: var(--moon); }
.bar-row.on p + p { color: var(--moon); }
@keyframes grow { from { transform: scaleX(0); } }

/* Steps 2 and 3 use the numbered .step layout from site.css */
.step-head h2 { margin-top: 12px; font-family: var(--display); font-size: 2.25rem; font-weight: 800; line-height: 1; }
.step-body { flex: 3 1 560px; min-width: 0; }
.step-body .cues { margin-top: 0; }
.step-body .sticky-sentence { max-width: 620px; margin-top: 30px; animation: stick .4s cubic-bezier(.2, 1.5, .4, 1) .15s backwards; }
/* The note is slapped onto the page: it starts big and crooked, then settles */
@keyframes stick { from { opacity: 0; transform: rotate(5deg) scale(1.15); } }
.plan-note { margin-top: 24px; max-width: 560px; color: var(--muted); }
.plan-note a { color: var(--text); text-decoration-color: var(--moon); }
.tips { max-width: 620px; padding-left: 1.2em; }
.tips li { margin-top: 12px; }
.tips li::marker { color: var(--moon); font-weight: 800; }
.tips a { text-decoration-color: var(--moon); }

.tool-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.button-quiet { background: transparent; color: var(--text); border: 2px solid var(--text); }
.button-quiet:hover { background: var(--text); color: var(--ink); }
button.button { border: 0; font: inherit; font-weight: 800; cursor: pointer; }
button.button-quiet { border: 2px solid var(--text); }

.tool-result + .wrap .storey { margin-top: 72px; }

/* ── The reading part of the page ───────────────────────────── */

.prose { max-width: 800px; margin-inline: auto; padding-top: 104px; padding-inline: clamp(20px, 4vw, 40px); }
.prose h2 {
  margin-top: 72px;
  padding-top: 26px;
  border-top: 3px solid var(--text);
  font-family: var(--display);
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  font-weight: 900;
  line-height: .95;
  text-wrap: balance;
  scroll-margin-top: 16px;
}
.prose h2:first-child { margin-top: 0; }
.prose p { margin-top: 16px; }
.prose ul, .prose ol { margin-top: 16px; padding-left: 1.2em; }
.prose li { margin-top: 8px; }
.prose li::marker { color: var(--moon); font-weight: 800; }
.prose a { text-decoration-color: var(--moon); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.prose .pull {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--moon);
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.625rem, 2.6vw, 2.125rem);
  font-weight: 800;
  line-height: 1.05;
}

/* Tables scroll sideways on small screens instead of squeezing */
.table-scroll { margin-top: 24px; overflow-x: auto; background: var(--panel); }
.table-scroll table { width: 100%; min-width: 520px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-scroll th, .table-scroll td { padding: 12px 16px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-scroll th:first-child, .table-scroll td:first-child { text-align: left; }
.table-scroll thead th { border-bottom: 3px solid var(--text); font-size: .875rem; font-weight: 800; }
.table-scroll tbody th { font-weight: 800; }
.table-scroll tbody tr:last-child th, .table-scroll tbody tr:last-child td { border-bottom: 0; }
.table-scroll td.hot { color: var(--moon); font-weight: 800; }
.table-scroll td.wrap-text { white-space: normal; text-align: left; min-width: 220px; }
.prose .small { font-size: .9375rem; color: var(--muted); }

/* ── Small screens ──────────────────────────────────────────── */

@media (max-width: 560px) {
  .time-field input { height: 80px; font-size: 3.5rem; }
  .tool-result { padding-top: 56px; }
  .result-row { padding-bottom: 56px; }
  .stats { gap: 0 20px; }
  .stats dd { font-size: 1.5rem; }
  .tool-actions .button { width: 100%; }
  .table-scroll th, .table-scroll td { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .rise, .bar i, .step-body .sticky-sentence { animation: none; }
  .cue, .button { transition: none; }
}
