/* Jazz: a focus timer kept by a black labradoodle.
   Built on the Harrison & Munro tokens (paper, ink, moss, Montserrat).
   Jazz's own colour is lilac: her bed, her icon. Breaks turn the paper to grass. */

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/montserrat-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/montserrat-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f4f3ef;
  --surface: #fbfaf7;
  --sunken: #ebe9e2;
  --line: #dcd8cc;
  --line-strong: #8f8b7d;
  --ink: #1b1b18;
  --ink-muted: #5a584f;
  --accent: #35552f;
  --accent-hover: #2a4425;
  --accent-ink: #ffffff;
  --grass: #e1ead9;
  --lilac: #c9b8e0;
  --lilac-soft: #e4daf0;
  --lilac-deep: #8e78ad;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 56px;

  --r-card: 16px;
  --r-ctl: 12px;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body[data-phase="short"],
body[data-phase="long"] {
  background: var(--grass);
}

@media (prefers-reduced-motion: no-preference) {
  body {
    transition: background-color 0.8s ease;
  }
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 0 var(--s5) var(--s6);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* top bar */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--s3);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: inherit;
}

.wordmark img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(27, 27, 24, 0.06);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the stage: Jazz in her bed, the bed rim is the timer */
.stage {
  position: relative;
  margin-top: calc(var(--s5) * -1);
}

.stage svg.scene {
  display: block;
  width: 100%;
  height: auto;
}

.bed-rim {
  fill: none;
  stroke: var(--lilac);
  stroke-width: 26;
}

.bed-cushion {
  fill: var(--lilac-soft);
}

.bed-stitch {
  fill: none;
  stroke: var(--lilac-deep);
  stroke-width: 1.5;
  stroke-dasharray: 4 6;
  opacity: 0.55;
}

.bed-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
}

.pose {
  display: none;
}

.stage[data-pose="sleep"] .pose-sleep,
.stage[data-pose="awake"] .pose-awake,
.stage[data-pose="play"] .pose-play {
  display: inline;
}

@media (prefers-reduced-motion: no-preference) {
  .pose-sleep .breathe {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: breathe 4.2s ease-in-out infinite;
  }
  .pose-sleep .head {
    transform-box: fill-box;
    transform-origin: 70% 90%;
    animation: breathe-head 4.2s ease-in-out infinite;
  }
  .zzz path {
    animation: drift 4.2s ease-in-out infinite;
    opacity: 0;
  }
  .zzz .z2 {
    animation-delay: 1.4s;
  }
  .pose-play .tail {
    transform-box: fill-box;
    transform-origin: 20% 100%;
    animation: wag 0.36s ease-in-out infinite alternate;
  }
  .stage[data-pose="play"].arrived .pose-play {
    animation: hop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 2;
  }
  .pose-awake .ear {
    transform-box: fill-box;
    transform-origin: 50% 0;
    animation: twitch 6s ease-in-out infinite;
  }
}

@keyframes breathe {
  50% { transform: scaleY(1.035); }
}

@keyframes breathe-head {
  50% { transform: translateY(-1.5px); }
}

@keyframes drift {
  0% { opacity: 0; transform: translate(0, 6px); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-8px, -14px); }
}

@keyframes wag {
  from { transform: rotate(-14deg); }
  to { transform: rotate(14deg); }
}

@keyframes hop {
  40% { transform: translateY(-10px); }
}

@keyframes twitch {
  0%, 92%, 100% { transform: rotate(0); }
  95% { transform: rotate(-8deg); }
}

/* readout */
.readout {
  text-align: center;
  margin-top: calc(var(--s2) * -1);
}

.time {
  display: block;
  font-size: clamp(4rem, 19vw, 5.75rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.status {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: var(--s4) 0 0;
  letter-spacing: -0.01em;
}

.sub {
  margin: var(--s1) auto 0;
  color: var(--ink-muted);
  max-width: 30ch;
}

/* controls */
.controls {
  display: flex;
  gap: var(--s3);
  justify-content: center;
  margin-top: var(--s5);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding-inline: var(--s4);
  border-radius: 999px;
  font-size: 1rem;
  white-space: nowrap;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  flex: 1 1 0;
  max-width: 220px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-quiet {
  background: transparent;
  border-color: var(--line-strong);
}

.btn-quiet:hover {
  background: rgba(27, 27, 24, 0.05);
}

.btn[hidden] {
  display: none;
}

/* desk / pocket */
.mode {
  margin-top: var(--s6);
  text-align: center;
}

.switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 999px;
  background: rgba(27, 27, 24, 0.06);
  border: 0;
  margin: 0;
}

.switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.switch label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding-inline: var(--s5);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--ink-muted);
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.switch label:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(27, 27, 24, 0.12);
}

.switch label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.switch svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-help {
  margin: var(--s2) auto 0;
  font-size: 0.875rem;
  color: var(--ink-muted);
  max-width: 34ch;
}

.notice {
  margin: var(--s3) auto 0;
  padding: var(--s3) var(--s4);
  max-width: 36ch;
  border-radius: var(--r-ctl);
  background: #f3e6c8;
  color: #6b4a12;
  font-size: 0.875rem;
  text-align: left;
}

.notice[hidden] {
  display: none;
}

/* today's balls */
.today {
  margin-top: auto;
  padding-top: var(--s6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

.balls {
  display: flex;
  gap: 4px;
}

.balls svg {
  width: 18px;
  height: 18px;
}

/* name card and settings */
.hello {
  margin-top: var(--s4);
  padding: var(--s5);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
}

.hello h1 {
  font-size: 1.375rem;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
}

.hello p {
  margin: var(--s1) 0 var(--s4);
  color: var(--ink-muted);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: var(--s4);
}

.field label {
  font-weight: 600;
  font-size: 0.9375rem;
}

.field .hint {
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.field input {
  font: inherit;
  min-height: 48px;
  padding: 0 var(--s4);
  border-radius: var(--r-ctl);
  border: 1.5px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.field input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.row3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s3);
}

.row3 .field input {
  padding-inline: var(--s3);
  text-align: center;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--r-card);
  padding: var(--s5);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(27, 27, 24, 0.45);
}

dialog::backdrop {
  background: rgba(27, 27, 24, 0.35);
}

dialog h2 {
  margin: 0 0 var(--s4);
  font-size: 1.25rem;
}

.dialog-tests {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding-top: var(--s4);
  margin-top: var(--s2);
  border-top: 1px solid var(--line);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
  min-height: 40px;
  padding-inline: var(--s3);
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  border-color: var(--line-strong);
}

.dialog-actions {
  display: flex;
  gap: var(--s3);
  justify-content: flex-end;
  margin-top: var(--s5);
}

.dialog-actions .btn {
  flex: 0 1 auto;
  min-height: 46px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s5);
  transform: translateX(-50%);
  padding: var(--s3) var(--s4);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  max-width: calc(100vw - 32px);
}

.toast[hidden] {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
