/* =====================================================================
   VOICEFOLK — overlays.css : the "internal pages" (sheets), modals, forms
   ===================================================================== */
dialog { padding: 0; border: 0; max-width: none; max-height: none; color: var(--ink); background: transparent; }
dialog::backdrop { background: rgb(27 26 23 / .62); }

/* ---- page sheets (slide in from the right) ---- */
.sheet { margin: 0 0 0 auto; height: 100%; width: min(780px, 100%); }
.sheet__panel {
  height: 100%; display: flex; flex-direction: column; background: var(--paper);
  box-shadow: -18px 0 50px rgb(27 26 23 / .25);
  border-left: 1px solid transparent;
  border-image: url("../ui/frame-card.svg") 30 / 0 0 0 26px stretch;
}
.sheet__head, .modal__head, .menu__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: calc(env(safe-area-inset-top, 0px) + 1.25rem) max(20px, env(safe-area-inset-right, 0px)) 1rem max(24px, env(safe-area-inset-left, 0px));
}
.sheet__head { position: sticky; top: 0; z-index: 2; background: var(--paper); border-bottom: 1px dashed var(--line); }
.sheet__title, .modal__title { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); margin-top: .15rem; }
.dlg__close {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center; color: var(--ink); background: none;
  border: 2px solid transparent; border-image: url("../ui/frame-pill-card.svg") 30 fill / 22px stretch;
}
.dlg__close .icon { width: 22px; height: 22px; }
.dlg__close:hover { border-image: url("../ui/frame-pill-ink.svg") 30 fill / 22px stretch; color: var(--paper); }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; flex: 1; padding: 1.75rem max(24px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 2.5rem) max(24px, env(safe-area-inset-left, 0px)); }
.sheet__illus { width: 180px; margin: 0 0 1rem; }
.sheet__tools { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.sheet__copied { font-family: var(--hand); font-weight: 400; font-size: 1.35rem; color: var(--tomato-ink); }
.sheet__back { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px dashed var(--line); }
.sheet__back a { font-weight: 600; display: inline-flex; min-height: 44px; align-items: center; }

/* ---- prose (fragments) ---- */
.prose { max-width: 62ch; display: grid; gap: 1rem; }
.prose h2 { font-size: 1.55rem; margin-top: 1.25rem; font-variation-settings: "opsz" 32; }
.prose h3 { font-size: 1.2rem; font-variation-settings: "opsz" 24; margin-top: .5rem; }
.prose p, .prose li { color: var(--ink-2); }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3rem; display: grid; gap: .55rem; margin: 0; }
.prose .lede { font-size: 1.15rem; color: var(--ink); line-height: 1.55; }
.prose .note { padding: 1rem 1.2rem; background: url("../ui/wash-peach.webp") center / 100% 100% no-repeat; color: var(--ink); border-radius: 4px; }
.prose ol.checklist { list-style: none; padding: 0; counter-reset: c; gap: 1rem; }
.prose ol.checklist li { counter-increment: c; position: relative; padding: 1.1rem 1.2rem 1.1rem 4rem; border: 1px solid transparent; border-image: url("../ui/frame-card-paper.svg") 30 fill / 24px stretch; }
.prose ol.checklist li::before {
  content: counter(c); position: absolute; left: 1.1rem; top: 1.05rem; width: 2.1rem; height: 2.1rem; display: grid; place-items: center;
  font: 700 1rem/1 var(--display); color: var(--paper); background: url("../ui/circle-ink.svg") center / 100% 100% no-repeat;
}
.prose ol.checklist h3 { margin: 0 0 .3rem; }

/* ---- modals (forms) ---- */
.modal { margin: auto; width: min(640px, calc(100% - 32px)); max-height: calc(100% - 32px); }
.modal__panel {
  position: relative; display: flex; flex-direction: column; max-height: calc(100dvh - 32px);
  background: var(--paper); border: 1px solid transparent;
  border-image: url("../ui/frame-card-paper.svg") 30 fill / 26px stretch;
  filter: drop-shadow(5px 6px 0 var(--ink));
}
.modal__body { overflow-y: auto; overscroll-behavior: contain; padding: 0 max(24px, env(safe-area-inset-right, 0px)) 1.75rem max(24px, env(safe-area-inset-left, 0px)); }
.modal__intro { color: var(--ink-2); margin-bottom: 1.25rem; }
@media (max-width: 599.98px) {
  .modal { margin: auto 0 0; width: 100%; max-height: 94dvh; }
  .modal__panel { max-height: 94dvh; filter: none; border-image-width: 26px 0 0 0; }
  .modal__body { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1.5rem); }
}

/* ---- forms ---- */
.vf-form { display: grid; gap: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
@media (max-width: 519.98px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: .35rem; min-width: 0; }
.field__label { font-weight: 600; font-size: .95rem; padding: 0; }
.req { color: var(--tomato-ink); margin-left: .15em; }
.opt { font-weight: 400; color: var(--ink-2); }
.field__help { font-size: .85rem; color: var(--ink-2); }
.input {
  width: 100%; min-height: 48px; padding: .7em .95em; font-size: 1rem; line-height: 1.4;
  background: none; color: var(--ink); border: 2px solid transparent; border-radius: 0;
  border-image: url("../ui/frame-input.svg") 20 fill / 14px stretch;
  -webkit-appearance: none; appearance: none;
}
select.input {
  padding-right: 2.6rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9.5 C9 12 10.5 13.5 12 15 C14 13 15.5 11.5 18 9' fill='none' stroke='%231B1A17' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") right .85rem center / 18px no-repeat;
}
textarea.input { min-height: 96px; resize: vertical; }
.input::placeholder { color: #8A8378; }
.input:focus-visible { outline: 3px solid var(--slate); outline-offset: 2px; }
.field__err { display: none; font-size: .85rem; font-weight: 600; color: var(--tomato-ink); }
.input:user-invalid { border-image: url("../ui/frame-pill-tomato.svg") 30 / 14px stretch; background-color: #FFF5F1; }
.input:user-invalid ~ .field__err { display: block; }
.checks { border: 0; margin: 0; padding: 0; display: grid; gap: .6rem; min-width: 0; }
.checks__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem .9rem; }
.checks__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 519.98px) { .checks__grid, .checks__grid--3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.check { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .6rem; min-height: 32px; }
.check input {
  -webkit-appearance: none; appearance: none; margin: .1rem 0 0; width: 24px; height: 24px; flex: none; cursor: pointer;
  background: url("../ui/frame-box.svg") center / 100% 100% no-repeat;
}
.check--radio input { background: url("../ui/circle-mustard.svg") center / 100% 100% no-repeat; filter: grayscale(1) brightness(1.6) contrast(.9); }
.check input:checked { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12 C7 13 9 15 10 17 C13 12 17 7 20 5' fill='none' stroke='%23FFFCF6' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat, url("../ui/frame-box-ink.svg") center / 100% 100% no-repeat; filter: none; }
.check--radio input:checked { background: radial-gradient(circle, var(--paper) 0 3.5px, transparent 4px), url("../ui/circle-ink.svg") center / 100% 100% no-repeat; }
.check input:focus-visible { outline: 3px solid var(--slate); outline-offset: 2px; }
.check label { font-size: .95rem; line-height: 1.45; cursor: pointer; padding-top: .1rem; }
.check .field__err { grid-column: 2; }
.check--req input:user-invalid:not(:checked) { background: url("../ui/frame-box.svg") center / 100% 100% no-repeat; outline: 2px solid var(--tomato); outline-offset: 1px; border-radius: 6px; }
.check--req input:user-invalid ~ .field__err { display: block; }
.btn--block { width: 100%; margin-top: .3rem; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.copyable { user-select: all; font-weight: 600; color: var(--ink); }

.form-success { display: grid; gap: .75rem; justify-items: start; padding: .5rem 0 .5rem; outline: none; }
.form-success__icon { width: 56px; height: 56px; padding: 12px; color: var(--paper); background: url("../ui/circle-ink.svg") center / 100% 100% no-repeat; }
.form-success__title { font-size: 1.9rem; }
.form-success p { color: var(--ink-2); }
.form-success__preview { font-family: var(--hand); font-weight: 400; font-size: 1.25rem; color: var(--tomato-ink) !important; }

/* ---- mobile menu ---- */
.menu { margin: 0; width: 100%; height: 100%; }
.menu__panel { height: 100%; display: flex; flex-direction: column; background: var(--paper); overflow-y: auto; }
.menu__head { align-items: center; border-bottom: 1px dashed var(--line); }
.menu__list { list-style: none; margin: 0; padding: 1.5rem max(24px, env(safe-area-inset-left, 0px)); display: grid; gap: .25rem; }
.menu__list a { display: flex; align-items: center; min-height: 56px; font: 700 clamp(1.8rem, 7vw, 2.4rem)/1.1 var(--display); color: var(--ink); text-decoration: none; }
.menu__list a:hover { color: var(--tomato-ink); }
.menu__actions { display: grid; gap: .8rem; padding: 0 max(24px, env(safe-area-inset-right, 0px)) 1.5rem max(24px, env(safe-area-inset-left, 0px)); }
.menu__hand { margin-top: auto; padding: 1rem max(24px, env(safe-area-inset-left, 0px)) calc(env(safe-area-inset-bottom, 0px) + 1.5rem); font: 400 1.8rem/1 var(--hand); color: var(--tomato-ink); }

/* ---- motion ---- */
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] .sheet__panel { animation: vf-slide-in .35s var(--ease) both; }
  .modal[open] .modal__panel, .menu[open] .menu__panel { animation: vf-pop .28s var(--ease) both; }
  dialog[open]::backdrop { animation: vf-fade .25s ease both; }
}
@keyframes vf-slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vf-pop { from { transform: translateY(14px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vf-fade { from { opacity: 0; } to { opacity: 1; } }
.link-btn { background: none; border: 0; padding: 0; min-height: 44px; font-weight: 600; color: var(--tomato-ink); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .18em; cursor: pointer; }
.link-btn:hover { text-decoration-thickness: 2.5px; }

/* ---- edge fixes (torn paper instead of stretched frames) ---- */
.sheet { filter: drop-shadow(-10px 0 28px rgb(27 26 23 / .28)); }
.sheet__panel { position: relative; border: 0; border-image: none; box-shadow: none; }
.sheet__panel::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -15px; width: 16px; pointer-events: none;
  background: url("../ui/edge-paper-left.svg") center / 100% 100% no-repeat;
}
@media (max-width: 779.98px) { .sheet { filter: none; } .sheet__panel::before { display: none; } }

/* desktop form modals: the hand-drawn frame IS the paper, so no square background behind it */
.modal__panel { background: none; }
@media (max-width: 599.98px) {
  .modal__panel { background: var(--paper); border: 0; border-image: none; filter: drop-shadow(0 -6px 18px rgb(27 26 23 / .25)); }
  .modal__panel::before {
    content: ""; position: absolute; left: 0; right: 0; top: -13px; height: 14px; pointer-events: none;
    background: url("../ui/edge-paper-top.svg") center / 100% 100% no-repeat;
  }
  .modal { overflow: visible; }
}
.sheet__title:focus, .modal__title:focus { outline: none; }
.sheet { overflow: visible; }

/* mobile menu fix: beat the ul[role=list] reset, give links proper spacing and targets */
ul.menu__list[role="list"] {
  list-style: none; margin: 0; display: grid; gap: 0;
  padding: 1rem max(24px, env(safe-area-inset-right, 0px)) 1.25rem max(24px, env(safe-area-inset-left, 0px));
}
.menu__list li { border-bottom: 1.5px dashed var(--line); }
.menu__list a { min-height: 64px; padding-block: .35rem; font-size: clamp(1.7rem, 7vw, 2.2rem); }
.menu__actions { padding-top: .5rem; }
.menu__actions .btn { width: 100%; }
.menu__head { padding-top: calc(env(safe-area-inset-top, 0px) + .9rem); padding-bottom: .9rem; }
.menu__hand { text-align: left; }

/* =====================================================================
   Pages: every route except the menu opens in place of <main>,
   between the site header and footer, so it feels like a page change.
   ===================================================================== */
html.is-page main { display: none; }
.page-host > dialog[open] {
  position: static; display: block; inset: auto; width: 100%; max-width: none; height: auto; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: visible; filter: none; background: var(--paper); color: var(--ink);
}
.page-host .sheet__panel, .page-host .modal__panel {
  display: block; height: auto; max-height: none; background: none; border: 0; border-image: none;
  box-shadow: none; filter: none; animation: none; position: static;
}
.page-host .sheet__panel::before, .page-host .modal__panel::before { display: none; }
.page-host .sheet__head, .page-host .modal__head {
  position: relative; display: block; top: auto; z-index: 0; border: 0;
  background: var(--paper-2);
  padding: clamp(1.25rem, 1rem + 1vw, 2rem) max(var(--gutter-r), calc((100% - 46rem) / 2)) clamp(2.25rem, 1.75rem + 2vw, 3.25rem) max(var(--gutter-l), calc((100% - 46rem) / 2));
  margin-bottom: clamp(2.5rem, 2rem + 2vw, 3.75rem);
}
.page-host .sheet__head::after, .page-host .modal__head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -23px; height: 24px; pointer-events: none;
  background: url("../ui/edge-paper2-bottom.svg") center / 100% 100% no-repeat;
}
.page-host .dlg__close { display: none; }
.page-host .sheet__title, .page-host .modal__title { font-size: clamp(2.3rem, 1.6rem + 3vw, 3.6rem); line-height: 1.02; margin-top: .25rem; text-wrap: balance; }
.page-host .sheet__body, .page-host .modal__body {
  overflow: visible; max-height: none;
  padding: 0 max(var(--gutter-r), calc((100% - 46rem) / 2)) var(--band-y) max(var(--gutter-l), calc((100% - 46rem) / 2));
}
.page-host .prose { max-width: none; }
.page-back {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; margin: 0 0 clamp(.75rem, .5rem + 1vw, 1.5rem) -.15rem;
  padding: 0; background: none; border: 0; color: var(--ink); font: 600 1rem/1 var(--body); cursor: pointer;
}
.page-back .icon { width: 1.1em; height: 1.1em; transition: transform .2s var(--ease); }
.page-back:hover { color: var(--tomato-ink); }
.page-back:hover .icon { transform: translateX(-3px); }
.page-back:focus-visible { outline: 3px solid var(--slate); outline-offset: 3px; }
.modal__head .page-back { display: none; }
.page-host .modal__head .page-back { display: inline-flex; }
.sheet__head .page-back { display: none; }
.page-host .sheet__head .page-back { display: inline-flex; }
@media (prefers-reduced-motion: no-preference) {
  .page-host > dialog[open] { animation: vf-page-in .3s var(--ease) both; }
}
@keyframes vf-page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
