/*
 * «Бумага», compass's one style: light warm paper and ink, one deep-green accent. Golos Text for text,
 * Lora only for the date heading, the month and the big numbers (fonts.css). This file holds the tokens
 * and what every page shares — the top bar, buttons, inputs, sheets, toasts, dialogs, motion. The
 * screens live in overview.css, form.css and auth.css.
 *
 * The readability rules are permanent (the owner, 2026-11-16; spec/assets/readability_spec.rb holds
 * every stylesheet here to them): text ≥ 7:1 and secondary text ≥ 4.5:1 on every surface, check boxes
 * ≥ 3:1; font sizes in px, task titles ≥ 18px, body 16px, secondary ≥ 14px, nothing below 13px, buttons
 * ≥ 15px; targets ≥ 44px; calendar cells ≥ 56px with numbers ≥ 18px; sentence case, no letter-spacing.
 */
:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #ece6d9;
  --menu-bg: #fffdf8;
  --input-bg: #fffdf8;
  --row-hover: #f8f4ec;
  --text: #1d1a16;
  --text-2: #574f45;
  --line: #e6dfd1;
  --line-strong: #b8ad9a;
  --check-line: #8a7f6f;
  --accent: #2e6047;
  --accent-hover: #244d39;
  --on-accent: #ffffff;
  --danger: #7a2619;
  --late: #a5453a;
  --focus: #2e6047;
  --ring-track: #e9e2d4;
  --lvl-zero: #f1dcd3;
  --lvl-low: #e5eddb;
  --lvl-high: #cfe2c6;
  --lvl-full: #b3d4aa;
  --toast-bg: #1d1a16;
  --toast-text: #fffdf8;
  --alert-bg: #7a2619;
  --stamp: #285640;
  --flash: rgb(46 96 71 / 0.1);
  --menu-shadow: 0 12px 32px rgb(70 52 25 / 0.16);
  --sheet-shadow: 0 1px 0 #e2d9c6, 0 10px 30px rgb(80 60 30 / 0.07);
  --scraps: #2e6047, #b08a4a, #9c4f3c, #6b7f99;
  --font-text: "Golos Text", system-ui, sans-serif;
  --font-display: "Lora", Georgia, serif;
  --top-h: 64px;
}

.compass {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.compass *, .compass *::before, .compass *::after { box-sizing: border-box; }
.compass :where(a) { color: inherit; }
.compass :where(button, input, select, textarea) { font: inherit; color: inherit; }
.compass :where(h1, h2, h3, p, dl, dd, ol, ul) { margin: 0; }
.compass :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* A section the task form hides (task_form_controller.js) stays hidden whatever display it has. */
.compass [hidden] { display: none !important; }
.compass input[type="radio"], .compass input[type="checkbox"] { accent-color: var(--accent); }

/* The top bar: sticky, and the band the toasts show in. */
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.top__inner {
  max-width: 1440px; min-height: var(--top-h); margin: 0 auto; padding: 10px 32px;
  display: flex; align-items: center; gap: 8px 24px;
}
.top__brand {
  min-height: 44px; display: inline-flex; align-items: center;
  font-family: var(--font-display); font-size: 22px; font-weight: 600; text-decoration: none;
}
.top__nav { flex: 1 1 auto; display: flex; gap: 4px; }
.app-nav__link {
  min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: 10px;
  font-size: 16px; text-decoration: none; color: var(--text-2);
}
.app-nav__link:hover { background: var(--surface-2); color: var(--text); }
.app-nav__link.is-active { color: var(--text); font-weight: 650; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; text-decoration-color: var(--accent); }
.top__out { margin: 0; }

/* Buttons and inputs */
.button {
  min-height: 48px; padding: 0 18px; border: 1px solid transparent; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 16px; font-weight: 650; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.button:hover { background: var(--accent-hover); }
.button--quiet { background: var(--surface-2); color: var(--text); }
.button--quiet:hover { background: var(--line); }
.button--line { background: transparent; color: var(--text); border-color: var(--line-strong); font-weight: 500; }
.button--line:hover { background: var(--surface-2); }
.button--danger { background: transparent; color: var(--danger); border-color: var(--line-strong); font-weight: 500; }
.button--danger:hover { background: var(--lvl-zero); }
.button--wide { width: 100%; }
.top .button { min-height: 44px; font-size: 16px; }

.input {
  width: 100%; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--input-bg); color: var(--text); font-size: 16px;
}
.input::placeholder { color: var(--text-2); opacity: 1; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 16px; font-weight: 600; }
.tick { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; font-size: 16px; cursor: pointer; }
.tick__input { width: 22px; height: 22px; margin: 0; }

/* A sheet of paper */
.sheet { background: var(--surface); border-radius: 6px; box-shadow: var(--sheet-shadow); }

/* The toasts — after a change (layouts/_flash) and after a check-off (the day's own): at most two lines
   inside the sticky top bar's band, so they never cover a task's text. */
.toast {
  position: fixed; top: 8px; left: 16px; right: 16px; z-index: 40;
  width: fit-content; max-width: min(560px, calc(100vw - 32px)); margin-inline: auto; padding: 10px 20px;
  border-radius: 12px; background: var(--toast-bg); color: var(--toast-text); box-shadow: var(--menu-shadow);
  font-size: 16px; font-weight: 500; line-height: 1.3; text-align: center; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  pointer-events: none; opacity: 0; transform: translateY(-8px); transition: opacity 0.2s, transform 0.2s;
}
/* An empty toast stays rendered (only transparent): it is a live region, and a screen reader must
   already be tracking it when the first message arrives. */
.toast.is-visible { opacity: 1; transform: none; }
.toast--alert { background: var(--alert-bg); }
.toast--flash { animation: toast-in 0.3s ease-out forwards, toast-out 0.4s ease-in 4s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }

/* Dialogs: the check-off day picker (overview/_picker) and «В день…» (overview/_move). */
.dialog {
  width: min(440px, calc(100vw - 32px)); margin: auto; padding: 24px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--menu-bg); color: var(--text); box-shadow: var(--menu-shadow); font-family: var(--font-text);
}
.dialog::backdrop { background: rgb(29 26 22 / 0.45); }
.dialog__form { display: grid; gap: 12px; }
.dialog__title { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.25; }
.dialog__task { font-size: 16px; color: var(--text-2); overflow-wrap: anywhere; }
.dialog__task:empty { display: none; }
.dialog__options { display: grid; gap: 6px; }
.dialog__quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dialog__label { margin-top: 4px; font-size: 16px; font-weight: 600; }
.dialog__date { width: 100%; }
.dialog__hint { font-size: 15px; color: var(--text-2); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.option {
  min-height: 48px; padding: 4px 14px; border: 1px solid var(--line-strong); border-radius: 10px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 16px; cursor: pointer;
}
.option:has(input[type="radio"]:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--row-hover); }
.option input[type="radio"] { width: 20px; height: 20px; margin: 0; }
.option--date .dialog__date { flex: 1 1 150px; width: auto; }

/* The phone: two rows — the brand and «+ Задача», then the sections and «Выйти» (the ::after is a
   zero-height flex item that breaks the line between them). */
@media (max-width: 767px) {
  .top__inner { padding: 8px 16px; gap: 4px 12px; flex-wrap: wrap; }
  .top__inner::after { content: ""; order: 3; flex-basis: 100%; height: 0; }
  .top__brand { order: 1; margin-right: auto; }
  .top__inner > .button { order: 2; }
  .top__nav { order: 4; flex: 1 1 auto; margin-left: -12px; }
  .top__out { order: 5; }
}

/* Motion off for those who asked for none — but a flash still goes away after the same delay. */
@media (prefers-reduced-motion: reduce) {
  .compass *, .compass *::before, .compass *::after { animation: none !important; transition: none !important; }
  .compass .toast--flash { opacity: 1; transform: none; animation: toast-out 0.01s linear 4s forwards !important; }
}
