/* Habit Tools — tool.css
   Extra styles for tool pages (calculators, trackers, planners).
   Load it after site.css. Colours, fonts, buttons, tags, cards, the
   numbered steps 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, so the title and
   step 1 paint at once. 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); }

/* ── 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(--red); }
.tool-q {
  margin-top: 6px;
  font-family: var(--display);
  font-size: clamp(2rem, 3.2vw, 2.75rem);
  font-weight: 900;
  line-height: .95;
}

/* Hours and minutes, written large like a date on a calendar */
.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(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Big Shoulders Display", "Arial Narrow", sans-serif;
  font-size: 4.5rem;
  font-weight: 900;
  line-height: 1;
  -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(--red); outline-offset: 2px; }

.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: #9AA0A8; cursor: not-allowed; }

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

/* ── Result band (white paper, like the spotlight band at home) ── */

.tool-result { background: var(--paper); padding-block: 72px 40px; scroll-margin-top: 0; }
.tool-result:focus { outline: none; }
.tool-result .card { background: var(--wall); box-shadow: none; }
.tool-result .cue { background: var(--paper); }
.tool-result .cue[aria-pressed="true"] { background: var(--sticky); }

/* Wide screens: number and totals on the left, the year on the right.
   Narrow screens: number, then the year, then the totals. */
.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top year" "stats year";
  column-gap: 72px;
  padding-bottom: 72px;
}
.result-top { grid-area: top; }
.result-year { grid-area: year; 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" "year" "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(--red);
  font-variant-numeric: tabular-nums;   /* digits keep one width while it counts up */
}
.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(--ink); }
.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; }

/* The year, one square per day. A red X is a day's worth of hours on
   the phone; a yellow square is a day given back. */
.year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 16px; margin-top: 16px; }
.month-name { margin-bottom: 6px; font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.month-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.day { position: relative; aspect-ratio: 1; border: 1px solid var(--line); background: var(--paper); }
.day.x::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M8 9C15 16 23 24 32 32M31 8C24 16 16 24 8 32' fill='none' stroke='%23D92B23' stroke-width='5.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 88% no-repeat;
  animation: mark .2s both;
  animation-delay: var(--wait, 0ms);
}
.day.back { background: var(--sticky); border-color: var(--ink); animation: back .3s backwards; animation-delay: var(--wait, 0ms); }
@keyframes mark { from { opacity: 0; transform: scale(1.8) rotate(-12deg); } }
@keyframes back { from { background: var(--paper); border-color: var(--line); transform: scale(.4); } }

.year-key { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 18px; font-size: .875rem; font-weight: 700; color: var(--muted); }
.year-key span { display: inline-flex; align-items: center; gap: 8px; }
.year-key .day { width: 16px; }

/* 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 .card-label { margin-bottom: 10px; }
.step-body .result { margin-top: 30px; max-width: 16em; }
.step-body .sticky-sentence { max-width: 620px; margin-top: 30px; animation: stick .4s cubic-bezier(.2, 1.5, .4, 1) .15s backwards; }
/* The yellow 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-pick { margin-top: 26px; }

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

.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(--ink);
  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(--red); font-weight: 800; }
.prose a { text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.prose .pull {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--sticky);
  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(--paper); box-shadow: var(--shadow); }
.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(--ink); 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(--red); font-weight: 800; }
.prose .small { font-size: .9375rem; color: var(--muted); }

/* ── Japanese ───────────────────────────────────────────────── */

:lang(ja) .tool-intro h1 { font-size: clamp(2.5rem, 5vw, 4.75rem); font-weight: 800; line-height: 1.15; }
:lang(ja) .tool-q { font-size: clamp(1.5rem, 2.2vw, 1.875rem); font-weight: 800; line-height: 1.3; }
:lang(ja) .big-unit { font-size: clamp(1.5rem, 2.4vw, 2.125rem); font-weight: 800; line-height: 1.3; }
:lang(ja) .step-head h2 { font-size: 1.625rem; font-weight: 800; line-height: 1.3; }
:lang(ja) .stats dd { font-size: 1.5rem; }
:lang(ja) .prose h2 { font-size: clamp(1.625rem, 2.8vw, 2.25rem); font-weight: 800; line-height: 1.3; }
:lang(ja) .prose .pull { font-size: clamp(1.25rem, 2vw, 1.5rem); line-height: 1.5; }

/* Spanish and Portuguese titles run longer than the English one. */
:lang(es) .tool-intro h1, :lang(pt) .tool-intro h1 { font-size: clamp(3.25rem, 6.2vw, 6.25rem); }

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

@media (max-width: 560px) {
  .time-field input { height: 80px; font-size: 3.75rem; }
  .year { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; }
  .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, .day.x::after, .day.back, .step-body .sticky-sentence { animation: none; }
  .cue, .button { transition: none; }
}
