/* ==================================================================
   Empty my head (design spec §17) — the box and "Anything for today?"
   ==================================================================
   Loaded after timeline.css, whose --stone-*, --ink-* and --surface-*
   tokens it uses. The dialog carries .hf-emh-dialog on the MudDialog
   itself; nothing here reaches any other dialog.

   Two rules carry the look, as on the rest of the task dialogs:
   • Lighter than the page means you can act on it: the text box and the
     list of lines are the lit surface; the sheet is cream.
   • State is never told by colour alone: an added row gets a tint, its
     + becomes a check, and the word "Today" appears (WCAG 1.4.1).

   The preview under the text field is a mirror: identical font, size,
   line height, padding and wrapping, so every character sits exactly
   under its twin in the transparent textarea above it. Change one side
   and change the other in the same rule.
   ------------------------------------------------------------------ */

.hf-emh-dialog {
  --emh-lit: var(--surface-raised);
  --emh-text: 17px;
  --emh-leading: 1.6;
}

.hf-emh-dialog.mud-dialog {
  display: flex;
  flex-direction: column;
  height: min(700px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  border-radius: 20px;
  border: 1px solid var(--stone-200);
  background: var(--surface-base);
  color: var(--ink-primary);
  box-shadow:
    0 18px 44px -12px rgba(40, 25, 18, 0.28),
    0 2px 6px rgba(40, 25, 18, 0.08);
  overflow: hidden;
}

/* The title names the dialog for screen readers; the sheet draws its own heading. */
.hf-emh-dialog .mud-dialog-title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hf-emh-dialog .mud-dialog-content.hf-emh-content {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.emh-sheet {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.emh-sheet button { font: inherit; color: inherit; cursor: pointer; }
.emh-sheet button:disabled { cursor: default; }
.emh-sheet svg { display: block; }

.emh-grab { display: none; }

/* ---- top row: "Draft kept" and close ------------------------------- */

.emh-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 4px 6px 0 20px;
}

.emh-draft {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.emh-draft svg { width: 13px; height: 13px; }
.emh-box:not(.is-empty) .emh-draft { opacity: 1; transform: none; }

.emh-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
}

.emh-close svg { width: 20px; height: 20px; }
.emh-close:hover { background: var(--stone-100); color: var(--ink-primary); }

.emh-sheet button:focus-visible {
  outline: 2px solid var(--stone-600);
  outline-offset: 2px;
}

/* ---- body ---------------------------------------------------------- */

.emh-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 18px;
}

.emh-head { padding: 0 2px 12px; }

.emh-h {
  margin: 0;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--ink-primary);
}

.emh-s {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-muted);
}

.emh-notice {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--stone-100);
  font-size: 13px;
  color: var(--ink-primary);
  animation: emh-fade-in 220ms ease both;
}

/* ---- the box: a transparent field over its preview ---------------- */

.emh-editor {
  position: relative;
  flex: 1 1 auto;
  min-height: 140px;
  border: 1px solid var(--stone-200);
  border-radius: 16px;
  background: var(--emh-lit);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(40, 25, 18, 0.04), 0 8px 18px -12px rgba(74, 62, 46, 0.22);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.emh-editor:focus-within {
  border-color: var(--stone-400);
  box-shadow: 0 0 0 4px rgba(var(--stone-500-rgb), 0.14), 0 8px 18px -12px rgba(74, 62, 46, 0.22);
}

.emh-editor textarea,
.emh-mirror-in {
  box-sizing: border-box;
  margin: 0;
  padding: 16px 16px 16px 34px;
  font-family: inherit;
  font-size: var(--emh-text);
  font-weight: 400;
  font-style: normal;
  line-height: var(--emh-leading);
  letter-spacing: normal;
  word-spacing: normal;
  text-transform: none;
  text-indent: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  tab-size: 4;
}

.emh-editor textarea {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  overflow-y: auto;
  scrollbar-width: none;
  unicode-bidi: plaintext;
  text-align: start;
  /* The words are drawn by the preview underneath; the field keeps its caret and selection. */
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--stone-700);
}

.emh-editor textarea::-webkit-scrollbar { display: none; }

.emh-editor textarea::placeholder {
  color: var(--ink-faint);
  -webkit-text-fill-color: var(--ink-faint);
  opacity: 1;
}

.emh-editor textarea::selection {
  color: transparent;
  -webkit-text-fill-color: transparent;
  background: rgba(var(--stone-500-rgb), 0.28);
}

.emh-mirror {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.emh-mirror-in {
  min-height: 100%;
  color: var(--ink-primary);
}

.emh-ml {
  position: relative;
  min-height: calc(var(--emh-text) * var(--emh-leading));
  unicode-bidi: plaintext;
  text-align: start;
}

.emh-dots {
  position: absolute;
  right: calc(100% + 8px);
  top: 0;
  height: calc(var(--emh-text) * var(--emh-leading));
  display: flex;
  align-items: center;
  gap: 3px;
}

.emh-d {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stone-500);
}

.emh-d.o {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--stone-400);
}

.emh-d.pop { animation: emh-dot-pop 280ms cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }

@keyframes emh-dot-pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* What comes off fades; a repeat and a line with no words go quiet. */
.lx-mark { color: var(--ink-faint); opacity: 0.55; }
.lx-faint, .lx-dup { color: var(--ink-faint); }
.lx-over { text-decoration: underline dotted var(--stone-400); text-underline-offset: 4px; }

/* ---- the one tip ---------------------------------------------------- */

.emh-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 8px 4px 2px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-muted);
}

.emh-hint-i {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 15px;
  color: var(--stone-600);
}

.emh-hint-i svg { width: 15px; height: 15px; }
.emh-hint-t { animation: emh-fade-in 220ms ease both; }

@keyframes emh-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: none; }
}

/* ---- footer --------------------------------------------------------- */

.emh-foot {
  flex: 0 0 auto;
  display: grid;
  gap: 12px;
  padding: 12px 18px max(18px, env(safe-area-inset-bottom));
  background: var(--surface-base);
  border-top: 1px solid var(--stone-200);
  box-shadow: 0 -10px 18px -14px rgba(74, 62, 46, 0.28);
}

.emh-box .emh-foot { margin-top: 10px; }

.emh-sum { display: grid; gap: 7px; }

.emh-sum-r {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  font-size: 13.5px;
  line-height: 1.35;
}

.emh-sum-i {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--stone-100);
  color: var(--stone-600);
}

.emh-sum-i svg { width: 15px; height: 15px; }
.emh-sum-t { flex: 1 1 auto; min-width: 0; color: var(--ink-muted); }
.emh-sum-r.is-day .emh-sum-t { color: var(--ink-primary); font-weight: 600; }

.emh-primary {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--fill-primary);
  color: var(--on-fill) !important;
  font-size: 15px !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background-color 160ms ease, opacity 160ms ease;
}

.emh-primary:not(:disabled):hover { background: var(--fill-primary-hover); }
.emh-primary:disabled { opacity: 0.42; }

.emh-error {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--rust-500);
}

.emh-undo-link {
  justify-self: center;
  margin-top: -4px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  font-size: 12.5px !important;
  color: var(--ink-muted) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--stone-300);
}

.emh-undo-link:hover { color: var(--ink-primary) !important; }

/* ---- Anything for today? ------------------------------------------- */

.emh-pick {
  overflow-y: auto;
  padding-bottom: 18px;
  scrollbar-width: none;
}

.emh-pick::-webkit-scrollbar { display: none; }

.emh-ph {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 0 2px 12px;
}

.emh-ph .emh-s { padding-bottom: 6px; }
.emh-jar { flex: 0 0 auto; }
.emh-jar-drops circle { fill: var(--stone-500); animation: emh-jar-drop 620ms cubic-bezier(0.55, 0, 0.8, 0.2) 200ms both; }
.emh-jar-drops circle:nth-child(2) { animation-delay: 310ms; }
.emh-jar-drops circle:nth-child(3) { animation-delay: 420ms; }

@keyframes emh-jar-drop {
  from { transform: translateY(0); opacity: 1; }
  75% { opacity: 1; }
  to { transform: translateY(24px); opacity: 0; }
}

.emh-jar-fill {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: emh-jar-pour 820ms cubic-bezier(0.2, 0.8, 0.2, 1) 600ms both;
}

@keyframes emh-jar-pour {
  from { transform: scaleY(0.62); }
  to { transform: scaleY(1); }
}

.emh-pq {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
  padding: 10px 2px;
  background: var(--surface-base);
}

.emh-pq-t { flex: 1 1 210px; min-width: 0; }
.emh-pq-h { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-primary); }
.emh-pq-s { margin: 1px 0 0; font-size: 12.5px; color: var(--ink-muted); }

.emh-daysw {
  flex: 0 0 auto;
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--stone-300);
  border-radius: 999px;
  background: var(--emh-lit);
}

.emh-daysw button {
  min-height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px !important;
  font-weight: 600;
  color: var(--ink-muted) !important;
  transition: background-color 160ms ease, color 160ms ease;
}

.emh-daysw button[aria-pressed="true"] {
  background: var(--stone-600);
  color: var(--surface-base) !important;
}

.emh-plist {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--emh-lit);
  border: 1px solid var(--stone-200);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(40, 25, 18, 0.04), 0 8px 18px -12px rgba(74, 62, 46, 0.22);
}

.emh-plist li {
  position: relative;
  animation: emh-row-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 32ms + 160ms);
}

.emh-plist li + li::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--stone-100);
  z-index: 1;
}

@keyframes emh-row-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* The whole row is the button: at least 54px tall and the sheet's width (Fitts's law). */
.emh-prow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 11px 12px 11px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms ease;
}

.emh-prow:hover { background: var(--stone-50); }
.emh-prow.is-on { background: rgba(var(--stone-300-rgb), 0.22); }
.emh-prow.is-on:hover { background: rgba(var(--stone-300-rgb), 0.3); }

.emh-sheet .emh-prow:focus-visible {
  outline: 2px solid var(--stone-600);
  outline-offset: -3px;
  border-radius: 12px;
}

.emh-prow-t {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink-primary);
  overflow-wrap: anywhere;
  text-align: start;
}

/* A fixed-width slot, so a title never re-wraps when its control changes. */
.emh-prow-c { position: relative; flex: 0 0 96px; height: 32px; }

.emh-prow-c .add,
.emh-prow-c .on {
  position: absolute;
  right: 0;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform-origin: right center;
  transition: opacity 150ms ease, transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

.emh-prow-c .add {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--stone-300);
  color: var(--stone-600);
  background: var(--emh-lit);
  transform: translateY(-50%);
}

.emh-prow-c .add svg { width: 14px; height: 14px; }

.emh-prow-c .on {
  height: 30px;
  gap: 5px;
  padding: 0 12px 0 9px;
  border-radius: 999px;
  background: var(--stone-600);
  color: var(--surface-base);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-50%) scale(0.7);
}

.emh-prow-c .on svg { width: 14px; height: 14px; flex: 0 0 auto; }
.emh-prow.is-on .add { opacity: 0; transform: translateY(-50%) scale(0.6); }
.emh-prow.is-on .on { opacity: 1; transform: translateY(-50%) scale(1); }
.emh-prow .ck { stroke-dasharray: 16; stroke-dashoffset: 16; transition: stroke-dashoffset 240ms ease 70ms; }
.emh-prow.is-on .ck { stroke-dashoffset: 0; }

/* §11's day meter, compact: it describes the day and never limits it. */
.emh-meter { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; }

.emh-meter-bar {
  display: flex;
  width: 56px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--stone-100);
  box-shadow: inset 0 0 0 1px rgba(60, 40, 30, 0.06);
}

.emh-meter-bar i { display: block; height: 100%; transition: width 300ms ease; }
.emh-meter-bar .m-deep { background: var(--stone-700); }
.emh-meter-bar .m-solid { background: var(--stone-500); }
.emh-meter-bar .m-short { background: var(--amber-400, var(--amber-400)); }
.emh-meter-bar .m-quick { background: var(--stone-400); }
.emh-meter-l { min-width: 56px; font-size: 11.5px; font-weight: 600; color: var(--ink-muted); }

/* ---- the Someday page's undo line ---------------------------------- */

.emh-undo-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--stone-200);
  border-radius: 12px;
  background: var(--stone-50);
  font-size: 13.5px;
  color: var(--ink-primary);
}

.emh-undo-strip p { flex: 1 1 220px; margin: 0; }

.emh-undo-strip button {
  border: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--stone-700);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.emh-undo-strip button:focus-visible { outline: 2px solid var(--stone-600); outline-offset: 2px; }

/* ---- the ways in ---------------------------------------------------- */

/* Add task: "Lots on my mind?" under the title. */
.emh-door-link {
  align-self: flex-start;
  margin-top: -0.35rem;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--stone-700);
  text-decoration: underline;
  text-decoration-color: var(--stone-300);
  text-underline-offset: 3px;
  cursor: pointer;
}

.emh-door-link:hover { text-decoration-color: var(--stone-600); }
.emh-door-link:focus-visible { outline: 2px solid var(--stone-600); outline-offset: 2px; border-radius: 4px; }

/* Add task: a pasted list asks once. */
.emh-paste-ask {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--stone-200);
  border-radius: 12px;
  background: var(--stone-50);
  font-size: 0.875rem;
  color: var(--ink-primary);
}

.emh-paste-ask p { margin: 0; }
.emh-paste-ask .emh-paste-sub { color: var(--ink-muted); font-size: 0.8125rem; }
.emh-paste-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* The fresh-day screen: one line under "Add a task". */
.emh-fresh-door {
  align-self: center;
  margin-top: -0.15rem;
  padding: 6px 4px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink-muted);
  cursor: pointer;
}

.emh-fresh-door strong {
  font-weight: 600;
  color: var(--stone-700);
  text-decoration: underline;
  text-decoration-color: var(--stone-300);
  text-underline-offset: 3px;
}

.emh-fresh-door:focus-visible { outline: 2px solid var(--stone-600); outline-offset: 2px; border-radius: 6px; }

/* The phone + buttons: a held press must not select or call up the system menu. */
.emh-hold {
  display: inline-flex;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- phones: a sheet that fills what the keyboard leaves ------------ */

@media (max-width: 599.98px) {
  .hf-emh-dialog.mud-dialog {
    position: fixed;
    left: 0;
    right: 0;
    top: calc(var(--emh-vtop, 0px) + 10px);
    width: 100% !important;
    max-width: none !important;
    height: calc(var(--emh-vh, 100dvh) - 10px);
    max-height: none;
    margin: 0 !important;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
  }

  .emh-grab {
    display: block;
    flex: 0 0 auto;
    width: 36px;
    height: 5px;
    margin: 7px auto 0;
    border-radius: 999px;
    background: var(--stone-300);
  }

  .emh-top { min-height: 44px; padding-top: 0; }
  .emh-h { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .emh-d.pop,
  .emh-hint-t,
  .emh-notice,
  .emh-plist li,
  .emh-jar-fill { animation: none; }

  .emh-jar-drops { display: none; }

  .emh-draft,
  .emh-editor,
  .emh-prow,
  .emh-prow-c .add,
  .emh-prow-c .on,
  .emh-prow .ck,
  .emh-meter-bar i,
  .emh-daysw button,
  .emh-primary { transition: none; }
}
