/* ---------- Self-hosted timer font (Space Grotesk, SIL OFL — see assets/fonts/OFL.txt) ---------- */
@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/fonts/space-grotesk-400-normal.woff2') format('woff2'),
       url('assets/fonts/space-grotesk-400-normal.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-time: 'Space Grotesk', sans-serif;
  --pill: 999px;
  --fast: .2s;
}

/* ---------- Backgrounds (credits: assets/backgrounds/CREDITS.txt) ---------- */
[data-bg="starry"] { --bg-img: url("assets/backgrounds/starry.webp"); }
[data-bg="earth"]  { --bg-img: url("assets/backgrounds/earth.webp"); }
[data-bg="peaks"]  { --bg-img: url("assets/backgrounds/peaks.webp"); }
[data-bg="forest"] { --bg-img: url("assets/backgrounds/forest.webp"); }
[data-bg="shore"]  { --bg-img: url("assets/backgrounds/shore.webp"); }
[data-bg="field"]  { --bg-img: url("assets/backgrounds/field.webp"); }
[data-bg="night"]  { --bg-img: url("assets/backgrounds/night.webp"); }
[data-bg="dunes"]  { --bg-img: url("assets/backgrounds/dunes.webp"); }
[data-bg="lake"]   { --bg-img: url("assets/backgrounds/lake.webp"); }
[data-bg="meadow"] { --bg-img: url("assets/backgrounds/meadow.webp"); }
[data-bg="winter"] { --bg-img: url("assets/backgrounds/winter.webp"); }
[data-bg="moon"]   { --bg-img: url("assets/backgrounds/moon.webp"); }

/* script.js samples the part of the picture the clock sits on and sets
   data-theme, so the text switches between white and black to match */
body[data-theme="dark"]  { --fg: #ffffff; --panel: rgba(24, 26, 32, .7); }
body[data-theme="light"] { --fg: #17181c; --panel: rgba(255, 255, 255, .7); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  --soft: color-mix(in srgb, var(--fg) 12%, transparent);
  --line: color-mix(in srgb, var(--fg) 28%, transparent);
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg-img) center / cover no-repeat fixed;
  color: var(--fg);
  font-family: var(--font-ui);
}

button { font-family: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
button:focus-visible,
select:focus-visible,
input:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }

/* ---------- Timer ---------- */
main {
  position: relative;
  text-align: center;
  padding: 1rem;
}

/* halo behind the text so busy patches of the photo can't swallow it */
body[data-theme="dark"] main {
  text-shadow: 0 1px 4px rgba(0, 0, 0, .65), 0 0 16px rgba(0, 0, 0, .4),
               0 10px 44px rgba(0, 0, 0, .3);
}
body[data-theme="light"] main {
  text-shadow: 0 1px 3px rgba(255, 255, 255, .85), 0 0 14px rgba(255, 255, 255, .55);
}

.modes {
  display: inline-flex;
  gap: .25rem;
  padding: .3rem;
  border-radius: var(--pill);
  background: var(--soft);
}

.mode {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: .95rem;
  font-weight: 700;
  padding: .55rem 1.1rem;
  border-radius: var(--pill);
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.mode[aria-pressed="true"] { background: var(--fg); color: var(--panel); }

.stage { position: relative; }

.time {
  font-family: var(--font-time);
  font-weight: 400;
  font-size: clamp(4.5rem, 18vw, 12.5rem);
  line-height: 1;
  letter-spacing: -.03em;
  margin: .18em 0 .1em;
}

/* while the clock is being edited by double-click */
.time[contenteditable="true"] {
  outline: 2px dashed var(--line);
  outline-offset: 10px;
  border-radius: 8px;
  caret-color: var(--fg);
  cursor: text;
}

/* sits to the right of the digits without nudging anything else */
.suggest-box {
  position: absolute;
  left: calc(100% + .9rem);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
}
.suggest-note {
  position: absolute;
  left: 0;
  top: calc(100% + .4rem);
  font-size: .78rem;
  font-weight: 700;
  opacity: .85;
}

.controls { display: flex; gap: .75rem; justify-content: center; }

.btn {
  font-size: 1.05rem;
  font-weight: 800;
  padding: .8rem 2.2rem;
  border-radius: var(--pill);
  border: 2px solid var(--fg);
  cursor: pointer;
  transition: transform .12s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--fg); color: var(--panel); }
.btn.ghost { background: var(--panel); color: var(--fg); }

/* anchored below the centered clock block and invisible without ever
   freeing its space, so hiding it can't shift the timer; the solid panel
   pill is the inverse of the text color, so it stays readable over any photo */
.tip {
  position: absolute;
  top: calc(100% + 1.4rem);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding: .3rem .9rem;
  border-radius: var(--pill);
  background: var(--panel);
  font-size: .78rem;
}

.icon-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--fg);
  cursor: pointer;
  transition: transform var(--fast);
}
.icon-btn:hover { transform: rotate(20deg); }

/* the fullscreen button mirrors the settings button, from the bottom corner */
.icon-btn.bottom {
  top: auto;
  bottom: 1rem;
  z-index: 3; /* above the cat, which roams along the bottom edge */
}
#fullscreen .fs-exit { display: none; }
#fullscreen[data-active="true"] .fs-enter { display: none; }
#fullscreen[data-active="true"] .fs-exit { display: block; }

/* ---------- Settings dialog ---------- */
dialog {
  width: min(92vw, 27rem);
  max-height: 92vh;
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  color: var(--fg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); }

.panel { padding: 1.4rem 1.5rem 1.2rem; }
.panel h2 { margin: 0 0 .6rem; font-size: 1.3rem; font-weight: 800; }

fieldset { border: 0; margin: 0 0 1.3rem; padding: 0; min-width: 0; }
legend {
  padding: 0;
  margin-bottom: .6rem;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .75;
}

select {
  width: 100%;
  padding: .6rem .6rem;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
select option { background: var(--panel); color: var(--fg); }

.small {
  padding: .5rem .9rem;
  font-size: .85rem;
  font-weight: 700;
  color: var(--fg);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.small:hover { background: var(--soft); }

.hint { margin: .6rem 0 0; font-size: .8rem; line-height: 1.4; opacity: .8; }
.hint.top { margin: 0 0 1.3rem; }
.hint.center { text-align: center; margin-top: .9rem; }

.row { display: flex; gap: .5rem; align-items: stretch; }
.row select { flex: 1; }
.row .small { margin: 0; }

/* photo thumbnails, one per image in assets/backgrounds/ */
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.swatch {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
  background-image: var(--bg-img);
  background-size: cover;
  background-position: center;
}
.swatch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch:has(input:checked) { outline: 3px solid var(--fg); outline-offset: 2px; }
.swatch:has(input:focus-visible) { outline-style: dashed; }

.done { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* on narrower screens the suggestion button moves under the clock */
@media (max-width: 1000px) {
  .suggest-box {
    position: static;
    transform: none;
  }
  .suggest-note {
    position: static;
    display: block;
    margin-top: .3rem;
  }
}

@media (max-width: 420px) {
  .mode { padding: .5rem .8rem; font-size: .85rem; }
  .btn { padding: .75rem 1.7rem; }
}
