/* mikropaus — single stylesheet */

:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --text: #1b1a18;
  --text-muted: #6b6862;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --border: #dedbd5;
  --border-strong: #b9b4ab;
  --focus: #2f6f4f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1f2224;
    --text: #ecebe8;
    --text-muted: #9a978f;
    --accent: #6cc79a;
    --accent-text: #10231a;
    --border: #33383b;
    --border-strong: #4c5256;
    --focus: #6cc79a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
}

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

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Header ---------- */

.header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
}

.header__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.icon-button svg {
  width: 1.375rem;
  height: 1.375rem;
  fill: currentColor;
}

/* ---------- Main / views ---------- */

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem clamp(1rem, 4vw, 2rem) max(2rem, 8vh);
}

.view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 34rem;
  text-align: center;
}

.view[hidden] {
  display: none;
}

/* ---------- Clock ---------- */

.clock {
  font-size: clamp(5rem, 26vw, 14rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.clock--paused {
  color: var(--text-muted);
}

.clock__caption {
  margin: -0.75rem 0 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ---------- Break view ---------- */

.break__eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.break__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.break__activity {
  margin: 0;
  font-size: clamp(1.75rem, 6vw, 3rem);
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

.icon-button--help {
  width: 2rem;
  height: 2rem;
  flex: none;
  color: var(--accent);
}

.icon-button--help svg {
  width: 1.5rem;
  height: 1.5rem;
}

.icon-button--help[hidden] {
  display: none;
}

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.button {
  appearance: none;
  padding: 0.6875rem 1.375rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.button:hover {
  border-color: var(--text-muted);
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button--primary:hover {
  opacity: 0.88;
  border-color: var(--accent);
}

.button--small {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
}

.button[hidden] {
  display: none;
}

/* ---------- Settings dialog ---------- */

.dialog {
  /* Wide enough for the longest chip row — the six reminder presets
     (Aldrig / 1 / 2 / 3 / 5 / 10 min) — to sit on one line. They still wrap
     below this width, so narrow screens degrade gracefully. */
  width: min(35rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.dialog__form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 0;
  padding: 1.5rem;
}

.dialog__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.dialog__note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.field__label {
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.375rem 0.8125rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  /* Never break "10 min" across two lines when the row is tight. */
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover {
  border-color: var(--text-muted);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.field__custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.field__custom input {
  width: 5rem;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.field__check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
}

.field__check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.field__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.field__error {
  margin: 0;
  color: #c0392b;
  font-size: 0.8125rem;
}

@media (prefers-color-scheme: dark) {
  .field__error {
    color: #ff8a7a;
  }
}

.field__error[hidden] {
  display: none;
}

/* Test sound sits on its own line, left aligned */
#test-sound {
  align-self: flex-start;
}

/* ---------- Explain dialog / rendered markdown ---------- */

.dialog--wide {
  width: min(38rem, calc(100vw - 2rem));
  max-height: min(85vh, 48rem);
}

.dialog--wide .dialog__form {
  max-height: inherit;
}

.markdown {
  overflow-y: auto;
  line-height: 1.6;
  font-size: 0.9375rem;
}

.markdown > *:first-child {
  margin-top: 0;
}

.markdown > *:last-child {
  margin-bottom: 0;
}

.markdown h3,
.markdown h4,
.markdown h5 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.markdown p {
  margin: 0 0 0.875rem;
}

.markdown ul,
.markdown ol {
  margin: 0 0 0.875rem;
  padding-left: 1.375rem;
}

.markdown li {
  margin-bottom: 0.375rem;
}

.markdown a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.markdown code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bg);
  font-size: 0.9em;
}

/* Images and video scale to the dialog; wide media must never widen the page. */
.markdown .md-media {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.875rem 0;
  border-radius: 8px;
  background: var(--bg);
}

.markdown .md-embed {
  position: relative;
  margin: 0.875rem 0;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

.markdown .md-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

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