/* Encore family.css — opt-in shared patterns for the family apps.
   Load after encore-shell.css, then keep the app's own stylesheet last so its
   --es-* palette wins. Every colour in the patterns below comes from a token.
   Classes use the .es- prefix; pages that do not add those classes are unchanged.
   This sheet is not branded to any one app. */

:root {
  /* Additive tokens only. Do not reset --es-bg, --es-surface, --es-text, --es-muted,
     --es-line, --es-accent, --es-accent-text, --es-danger, --es-danger-btn, --es-danger-btn-text, --es-ok, --es-radius,
     --es-font, --es-max, --es-header-h or --es-scrim — those stay with the app. */
  --es-bg-2: var(--es-bg);
  --es-text-2: var(--es-muted);
  --es-text-3: var(--es-muted);
  --es-warn: var(--es-accent);

  --es-font-display: "Cormorant Garamond", Cormorant, Georgia, "Times New Roman", serif;
  --es-font-body: var(--es-font, "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif);

  --es-space-1: 4px;
  --es-space-2: 8px;
  --es-space-3: 12px;
  --es-space-4: 16px;
  --es-space-5: 20px;
  --es-space-6: 24px;
  --es-space-7: 32px;
  --es-space-8: 48px;
  --es-space-9: 64px;

  --es-radius-sm: 8px;
  --es-radius-control: var(--es-radius, 14px);
  --es-radius-card: 22px;
  --es-radius-sheet: 26px;
  --es-radius-pill: 999px;

  --es-fs-caption: 12px;
  --es-fs-label: 12px;
  --es-fs-body-sm: 13.5px;
  --es-fs-body: 15px;
  --es-fs-body-lg: 17px;
  --es-fs-title-3: 22px;
  --es-fs-title-2: 28px;
  --es-fs-title-1: 32px;
  --es-fs-hero: clamp(44px, 8vw, 78px);

  --es-ease: cubic-bezier(.22, .61, .36, 1);
  --es-dur-press: 150ms;
  --es-dur-state: 250ms;
  --es-dur-sheet: 450ms;

  --es-elev-1: 0 1px 2px color-mix(in srgb, var(--es-text) 8%, transparent);
  --es-elev-2: 0 1px 2px color-mix(in srgb, var(--es-text) 8%, transparent),
    0 16px 40px -16px color-mix(in srgb, var(--es-text) 18%, transparent);

  --es-tap: 44px;
}

@media (min-width: 861px) {
  :root { --es-fs-title-1: 38px; }
}

/* Type scale — opt in with a class. Titles use the serif display stack. */
.es-caption { font-family: var(--es-font-body); font-size: var(--es-fs-caption); line-height: 1.4; }
.es-label {
  font-family: var(--es-font-body);
  font-size: var(--es-fs-label);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--es-muted);
}
.es-body-sm { font-family: var(--es-font-body); font-size: var(--es-fs-body-sm); line-height: 1.5; }
.es-body { font-family: var(--es-font-body); font-size: var(--es-fs-body); line-height: 1.55; }
.es-body-lg { font-family: var(--es-font-body); font-size: var(--es-fs-body-lg); line-height: 1.5; }
.es-title-3, .es-title-2, .es-title-1, .es-hero {
  font-family: var(--es-font-display);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--es-text);
}
.es-title-3 { font-size: var(--es-fs-title-3); }
.es-title-2 { font-size: var(--es-fs-title-2); }
.es-title-1 { font-size: var(--es-fs-title-1); }
.es-hero { font-size: var(--es-fs-hero); font-weight: 400; }
.es-muted { color: var(--es-muted); }

/* Buttons: primary, secondary, quiet. Minimum 44px tap target. */
.es-btn.es-secondary,
.es-btn.es-quiet,
button.es-secondary,
button.es-quiet {
  font: inherit;
  font-family: var(--es-font-body);
  font-size: var(--es-fs-body);
  min-height: var(--es-tap);
  min-width: var(--es-tap);
  padding: 0 var(--es-space-5);
  border-radius: var(--es-radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--es-space-2);
  box-sizing: border-box;
}
/* Shared .es-btn already exists in the shell. Reinforce the 44px target and
   family motion when this sheet is loaded, without changing colour tokens. */
.es-btn {
  min-height: var(--es-tap);
  min-width: var(--es-tap);
  font-family: var(--es-font-body);
}
.es-btn.es-primary { background: var(--es-accent); color: var(--es-accent-text); border-color: transparent; }
.es-btn.es-danger { background: var(--es-danger-btn); color: var(--es-danger-btn-text); border-color: transparent; }
.es-btn.es-secondary {
  background: transparent;
  color: var(--es-text);
  border: 1px solid var(--es-line);
}
.es-btn.es-quiet {
  background: transparent;
  color: var(--es-text);
  border: 1px solid transparent;
}
.es-btn.es-secondary:hover,
.es-btn.es-quiet:hover { filter: brightness(1.08); }
.es-btn.es-secondary:disabled,
.es-btn.es-quiet:disabled,
.es-btn.es-danger:disabled,
.es-btn.es-primary:disabled { opacity: .45; cursor: default; filter: none; }

/* Cards */
.es-card {
  background: var(--es-surface);
  color: var(--es-text);
  border: 1px solid var(--es-line);
  border-radius: var(--es-radius-card);
  box-shadow: var(--es-elev-2);
  padding: var(--es-space-5);
  box-sizing: border-box;
}

/* Chips, including the "Shared with {name}" style */
.es-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--es-space-2);
  min-height: 28px;
  padding: var(--es-space-1) 10px;
  border-radius: var(--es-radius-pill);
  border: 1px solid var(--es-line);
  background: var(--es-surface);
  color: var(--es-text);
  font-family: var(--es-font-body);
  font-size: var(--es-fs-caption);
  line-height: 1;
  box-sizing: border-box;
}
.es-chip-shared { background: color-mix(in srgb, var(--es-accent) 14%, var(--es-surface)); border-color: color-mix(in srgb, var(--es-accent) 35%, var(--es-line)); }
.es-chip-private { color: var(--es-muted); }
.es-chip.es-dense { min-height: 22px; padding: 1px 7px; gap: 4px; }

/* Inputs */
.es-field { display: flex; flex-direction: column; gap: var(--es-space-2); }
.es-field .es-label { margin: 0; }
.es-input,
input.es-input,
textarea.es-input,
select.es-input {
  font-family: var(--es-font-body);
  font-size: 16px; /* 16px avoids iOS zoom; the type scale body is 15 */
  line-height: 1.4;
  color: var(--es-text);
  background: var(--es-surface);
  border: 1px solid var(--es-line);
  border-radius: var(--es-radius-control);
  min-height: var(--es-tap);
  padding: var(--es-space-2) var(--es-space-3);
  width: 100%;
  box-sizing: border-box;
}
textarea.es-input { min-height: calc(var(--es-tap) * 2); resize: vertical; padding: var(--es-space-3); }
.es-input::placeholder { color: var(--es-muted); }
.es-input:disabled { opacity: .55; }

/* Sheets / panels */
.es-sheet {
  background: var(--es-surface);
  color: var(--es-text);
  border: 1px solid var(--es-line);
  border-radius: var(--es-radius-sheet);
  box-shadow: var(--es-elev-2);
  padding: var(--es-space-6);
  max-width: 440px;
  width: 100%;
  box-sizing: border-box;
}
.es-sheet.es-wide { max-width: min(720px, 100%); width: 100%; }
@media (max-width: 520px) {
  .es-sheet {
    max-width: none;
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}
@media (max-width: 600px) {
  .es-sheet.es-wide {
    max-width: none;
    width: 100%;
    min-height: 0;
    border-radius: var(--es-radius-sheet) var(--es-radius-sheet) 0 0;
    border-left: 0;
    border-right: 0;
    padding: var(--es-space-6) max(var(--es-space-6), env(safe-area-inset-right, 0px)) calc(var(--es-space-6) + env(safe-area-inset-bottom, 0px)) max(var(--es-space-6), env(safe-area-inset-left, 0px));
  }
}

/* Empty state */
.es-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--es-space-3);
  padding: var(--es-space-8) var(--es-space-5);
  color: var(--es-text);
}
.es-empty .es-title-2, .es-empty .es-title-3 { margin: 0; }
.es-empty .es-body, .es-empty p { margin: 0; max-width: 28em; color: var(--es-muted); }
.es-empty .es-actions { margin-top: var(--es-space-3); display: flex; flex-wrap: wrap; gap: var(--es-space-2); justify-content: center; }

/* Footer line (shared with the shell's .es-foot) */
.es-foot, .es-footer, .es-footer-line {
  text-align: center;
  font-family: var(--es-font-body);
  font-size: 12px;
  color: var(--es-muted);
  padding: var(--es-space-6) var(--es-space-4) var(--es-space-8);
}

/* Focus rings */
.es-btn:focus-visible,
.es-chip:focus-visible,
.es-input:focus-visible,
.es-sheet :focus-visible,
.es-card :focus-visible,
.es-empty :focus-visible {
  outline: 2px solid var(--es-accent);
  outline-offset: 2px;
}

/* Motion */
.es-btn, .es-chip, .es-input, .es-card, .es-sheet {
  transition: filter var(--es-dur-press) var(--es-ease),
    background-color var(--es-dur-state) var(--es-ease),
    border-color var(--es-dur-state) var(--es-ease),
    opacity var(--es-dur-state) var(--es-ease);
}
@media (prefers-reduced-motion: reduce) {
  .es-btn, .es-chip, .es-input, .es-card, .es-sheet, .es-empty, .es-enter, .es-enter-cta, .es-update {
    transition: opacity 150ms, color 150ms;
    animation: none;
  }
  .es-enter-out { transition: none; }
}

/* Enter gate (shell.enter) and update bar (shell.update). Tokens only. */
.es-enter {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--es-bg);
  color: var(--es-text);
  padding: max(var(--es-space-6), env(safe-area-inset-top)) max(var(--es-space-6), env(safe-area-inset-right)) max(var(--es-space-6), env(safe-area-inset-bottom)) max(var(--es-space-6), env(safe-area-inset-left));
  box-sizing: border-box;
  cursor: pointer;
}
.es-enter-card { width: min(460px, 100%); text-align: center; }
.es-enter-title { margin: 0 0 var(--es-space-3); }
.es-enter-sub { margin: 0 0 var(--es-space-6); }
.es-enter-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: var(--es-tap);
  padding: var(--es-space-3) var(--es-space-6);
  border: 1px solid var(--es-line);
  border-radius: var(--es-radius-pill);
  font-family: var(--es-font-body);
  font-size: var(--es-fs-label);
  font-weight: 600;
  color: var(--es-muted);
}
.es-enter-out { opacity: 0; pointer-events: none; transition: opacity 350ms var(--es-ease, ease); }
@media (prefers-reduced-motion: no-preference) {
  .es-enter-cta {
    animation: es-enter-pulse 2.4s var(--es-ease, ease) infinite;
  }
}
@keyframes es-enter-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--es-accent) 0%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--es-accent) 22%, transparent); }
}

.es-update {
  position: fixed;
  left: max(var(--es-space-4), env(safe-area-inset-left));
  right: max(var(--es-space-4), env(safe-area-inset-right));
  bottom: var(--es-update-bottom, max(var(--es-space-4), env(safe-area-inset-bottom)));
  z-index: 150;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--es-space-3);
  padding: var(--es-space-3) var(--es-space-4);
  background: var(--es-surface);
  color: var(--es-text);
  border: 1px solid var(--es-line);
  border-radius: var(--es-radius-pill);
  box-shadow: var(--es-elev-2);
  box-sizing: border-box;
}
.es-update[hidden] { display: none !important; }
#es-update.es-update { bottom: var(--es-update-bottom, max(var(--es-space-4), env(safe-area-inset-bottom))); }
.es-update-line { margin: 0; flex: 1 1 auto; }
.es-update-go { flex: none; }
@media (max-width: 520px) {
  .es-update {
    flex-direction: column;
    align-items: stretch;
    border-radius: var(--es-radius-sheet);
    text-align: center;
  }
  .es-update-go { width: 100%; }
}
