/* layout: the Void family. the canvas fills the viewport, one translucent card floats over it, and
   the card fades while the sand runs (main.js sets .is-idle). a theme switch changes colour only. */

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

/* an author display rule must never beat the hidden attribute (house rule, invaders P3) */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background-color: var(--bg);
  /* the comb-ruled squares of an adinkra cloth: triple rules every 120px, both ways */
  background-image:
    repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 4px, var(--rule) 4px 5px, transparent 5px 8px, var(--rule) 8px 9px, transparent 9px 120px),
    repeating-linear-gradient(0deg, var(--rule) 0 1px, transparent 1px 4px, var(--rule) 4px 5px, transparent 5px 8px, var(--rule) 8px 9px, transparent 9px 120px);
  background-position: center;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 3;
  padding: var(--space-2) var(--space-3);
  background: var(--stamp);
  color: var(--stamp-ink);
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.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;
}

/* ---------------------------------------------------------------- the card */

.card {
  position: fixed;
  z-index: 2;
  left: var(--space-3);
  right: var(--space-3);
  bottom: var(--space-3);
  max-height: calc(100dvh - 2 * var(--space-3));
  overflow: auto;
  padding: var(--space-3);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  transition: opacity 400ms ease, visibility 0s linear 0s;
}

.card.is-idle {
  opacity: 0;
  visibility: hidden;
  transition: opacity 700ms ease, visibility 0s linear 700ms;
}

@media (min-width: 760px) {
  .card {
    left: var(--space-5);
    right: auto;
    bottom: var(--space-5);
    width: 320px;
  }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.head-actions {
  display: flex;
  flex: none;
  gap: var(--space-2);
}

/* the wordmark: thin sankofa letters reversed out of a bark-ink lino block, with a carved border
   line inside the block edge and gouge cuts along its foot */
.wordmark {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 9px 12px 11px;
  background: var(--stamp);
  color: var(--stamp-ink);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(22px, 7vw, 28px);
  line-height: 1;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.wordmark::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: var(--line) solid var(--stamp-ink);
  border-radius: 1px;
  opacity: 0.55;
  pointer-events: none;
}

.wordmark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 5px;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--stamp-ink) 0 1px, transparent 1px 4px);
  opacity: 0.55;
  pointer-events: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  background: transparent;
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.readout {
  margin: var(--space-3) 0 0;
  font-weight: 600;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.status {
  margin: var(--space-1) 0 0;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.duration-label {
  font-size: 12px;
  color: var(--muted);
}

.duration-input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.duration-input[aria-invalid='true'] {
  border-color: var(--alert);
  border-width: 2px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-1);
}

.preset-btn {
  min-height: var(--tap);
  padding: var(--space-1);
  background: var(--surface);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}

.preset-btn.is-pressed,
.preset-btn[aria-pressed='true'] {
  background: var(--stamp);
  color: var(--stamp-ink);
  border-color: var(--stamp);
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

.flip-btn {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--accent);
  color: var(--accent-ink);
  border: var(--line) solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
}

.mute-btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--space-2);
  background: transparent;
  color: var(--ink);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}

.mute-btn[aria-pressed='true'] {
  background: var(--surface);
  border-style: dashed;
}

.card.is-complete {
  box-shadow: 0 0 0 3px var(--glow);
}

.notice {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--alert);
  background: var(--surface);
  color: var(--ink);
}

.footer {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: var(--line) solid var(--rule);
  font-size: 12px;
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
}

/* focus is always visible, in a token measured against both grounds */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card.is-idle,
  .skip-link {
    transition: none;
  }
}

/* ---------------------------------------------------------------- the 404 page */

.card-lost {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

.text-link {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
