/* Home: features section — live replicas of the writing UI that play once on
   scroll-in (assets/home-features.js). Without the script every demo is its
   static end state. */

.hf {
  --hf-fill: rgba(27, 42, 65, 0.045);
  --hf-bezel: #1B1D22;
  --hf-card: var(--raised);
  --hf-add: rgba(156, 122, 69, 0.14);
  --hf-k: 0.8;
  --hf-screen: var(--paper);
  margin-top: clamp(56px, 2rem + 4vw, 112px);
  display: grid;
  gap: clamp(64px, 3rem + 4vw, 128px);
}
@media (prefers-color-scheme: dark) {
  .hf { --hf-fill: rgba(255, 255, 255, 0.06); --hf-add: rgba(201, 163, 102, 0.2); --hf-screen: #0F1012; }
}
@media (max-width: 700px) { .hf { --hf-k: 0.82; } }
@media (max-width: 380px) { .hf { --hf-k: 0.66; } }

/* One column that never outgrows the screen; the wide demos scroll inside their own frames. */
.hf-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(56px, 3rem + 2vw, 80px) clamp(24px, 1rem + 3vw, 72px); align-items: start; }
@media (min-width: 860px) {
  .hf-row--phones { grid-template-columns: repeat(2, max-content); justify-content: center; }
  .hf-fig--table { margin-top: clamp(48px, 6vw, 96px); }
  .hf-row--wide { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  .hf-fig--lock { margin-top: clamp(24px, 4vw, 72px); }
}
.hf-fig { margin: 0; position: relative; min-width: 0; }
.hf-fig::before { /* a soft brass wash behind each demo */
  content: ""; position: absolute; inset: -8% -10% 18%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, var(--glow), transparent 100%);
}
/* On narrow screens the wash stays within the demo's width: past it, it widened the page. */
@media (max-width: 1100px) { .hf-fig::before { inset: -8% 0 18%; } }
.hf-fig figcaption { margin-top: var(--s-5, 20px); max-width: 34ch; }
.hf-fig--write figcaption, .hf-fig--table figcaption { margin-inline: auto; width: calc(414px * var(--hf-k)); max-width: 100%; }
.hf-fig h3 { font-size: var(--t-h3); font-weight: 700; line-height: 1.3; letter-spacing: -0.008em; }
.hf-fig figcaption p { margin-top: var(--s-1, 4px); font-size: var(--t-body); color: var(--muted); }
.hf-replay {
  display: inline-flex; align-items: center; gap: 6px; margin: 12px 0 0 -10px; padding: 8px 12px 8px 10px; min-height: 44px;
  border: 0; border-radius: 22px; background: transparent; color: var(--ink); font: inherit; font-size: var(--t-small); font-weight: 600; cursor: pointer;
}
.hf-replay[hidden] { display: none; }
.hf-replay:hover { background: var(--hf-fill); }
.hf-replay svg { color: var(--brass-text); transition: transform 0.45s var(--ease-spring); }
.hf-replay:hover svg { transform: rotate(-90deg); }
.hf button:focus-visible, .hf [tabindex]:focus-visible, .hf input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Full-width rows inside a card: the ring goes inside, or the card's clip cuts its sides. */
.hf-hist button:focus-visible, .hf-lockcard button:focus-visible { outline-offset: -2px; }

/* ------------------------------------------------------------- the phone */
.hf-ph {
  --k: var(--hf-k);
  margin-inline: auto; box-sizing: content-box;
  width: calc(390px * var(--k)); padding: calc(12px * var(--k)) calc(12px * var(--k)) 0;
  border-radius: calc(58px * var(--k)) calc(58px * var(--k)) 0 0;
  background: var(--hf-bezel); box-shadow: inset 0 0 0 1.5px #3A3D45, 0 40px 80px -34px rgba(27, 42, 65, 0.5);
  -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent);
}
@media (prefers-color-scheme: dark) { .hf-ph { box-shadow: inset 0 0 0 1.5px #3A3D45, 0 40px 80px -34px #000; } }
.hf-vp { width: calc(390px * var(--k)); height: calc(560px * var(--k)); overflow: hidden; border-radius: calc(48px * var(--k)) calc(48px * var(--k)) 0 0; }
.hf-screen {
  display: flow-root; position: relative; width: 390px; height: 560px; transform: scale(var(--k)); transform-origin: 0 0; background: var(--hf-screen);
  font-family: "Karla", system-ui, sans-serif; color: var(--ink); line-height: normal; text-align: left;
}
.hf-screen p, .hf-screen h4 { margin: 0; }
.hf-screen svg { display: block; max-width: none; flex: none; }
.hf-island { position: absolute; top: 11px; left: 50%; width: 122px; height: 35px; margin-left: -61px; border-radius: 20px; background: #000; }
.hf-nav { display: flex; align-items: center; justify-content: space-between; height: 44px; margin-top: 44px; padding: 0 12px; background: var(--hf-screen); border-bottom: 1px solid var(--line); }
.hf-back { display: flex; align-items: center; gap: 2px; padding: 0 8px 0 4px; color: var(--brass-text); font-size: 17px; font-weight: 500; letter-spacing: -0.2px; }
.hf-act { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.hf-act b { padding: 0 8px; font-size: 17px; font-weight: 700; color: var(--brass-text); }
.hf-body { padding: 14px 20px 0; }
.hf-title { font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.5px; }
.hf-p { margin-top: 12px !important; font-size: 17px; line-height: 24px; }
.hf-screen mark { background: rgba(184, 147, 91, 0.26); color: inherit; border-radius: 3px; padding: 0 1px; margin: 0 -1px; transition: background-color 0.28s; }
@media (prefers-color-scheme: dark) { .hf-screen mark { background: rgba(201, 163, 102, 0.3); } }
.hf-screen code { font: 500 0.88em ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--hf-fill); border-radius: 5px; padding: 1px 5px; transition: background-color 0.28s; }

/* ------------------------------------------------------------ the editor */
.hf-ed { margin-top: 14px; font-size: 17px; line-height: 26px; }
.hf-ln { position: relative; min-height: 26px; }
.hf-ln[hidden] { display: none; }
.hf-ln h4 { font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: -0.3px; }
.hf-ln--h { margin-bottom: 4px; }
.hf-ln--task { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.hf-ln > p { padding-block: 0; }
.hf-ln--task span { transition: color 0.28s; }
.hf-ln--task:has(.hf-chk[aria-checked="true"]) span { color: var(--muted); }
.hf-chk {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 1.6px solid var(--muted); border-radius: 7px; background: transparent; color: transparent;
  transition: background-color 0.28s, border-color 0.28s, transform 0.45s var(--ease-spring);
}
.hf-chk svg { transform: scale(0.4); opacity: 0; transition: transform 0.45s var(--ease-spring), opacity 0.2s; }
.hf-chk[aria-checked="true"] { background: var(--brass); border-color: var(--brass); color: #1B2A41; }
.hf-chk[aria-checked="true"] svg { transform: none; opacity: 1; }
.hf-chk:active { transform: scale(0.9); }
.hf-raw { color: var(--ink); white-space: pre-wrap; }
.hf-raw i { font-style: normal; color: var(--muted); }
.hf-caret { display: inline-block; width: 2px; height: 22px; margin: 0 -1px; vertical-align: -4px; background: var(--brass); border-radius: 1px; }
.hf-caret.is-idle { animation: hf-blink 1.1s steps(1) infinite; }
@keyframes hf-blink { 50% { opacity: 0; } }
.hf-pop { animation: hf-pop 0.45s var(--ease-spring) both; }
@keyframes hf-pop { from { opacity: 0.2; transform: translateY(5px) scale(0.985); } }
.hf-pill {
  display: inline-flex; gap: 2px; margin-top: 18px; padding: 3px; height: 40px; box-sizing: border-box;
  background: var(--raised); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 4px 14px rgba(27, 42, 65, 0.12);
}
.hf-fmt { width: 40px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 16px; background: transparent; color: var(--ink); font: inherit; font-size: 17px; cursor: pointer; transition: background-color 0.2s; }
.hf-fmt[aria-pressed="true"] { background: var(--sel); }
.hf-fmt b { font-weight: 800; }
.hf-ed.off-b [data-fmt="b"] { font-weight: 400; }
.hf-ed.off-h [data-fmt="h"] { background: transparent; }
.hf-ed.off-c [data-fmt="c"] { background: transparent; font-family: inherit; font-weight: 400; padding: 0; }

/* -------------------------------------------------------------- the table */
.hf-tbl { position: relative; margin-top: 54px; margin-bottom: 14px; }
.hf-bar {
  position: absolute; left: 0; top: -42px; z-index: 2; display: inline-flex; align-items: center; height: 32px; box-sizing: border-box; padding: 0 3px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 14px rgba(27, 42, 65, 0.12);
  opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity 0.28s, transform 0.28s var(--ease-spring);
}
.hf-tbl:focus-within .hf-bar, .hf-tbl.is-ghost .hf-bar { opacity: 1; transform: none; pointer-events: auto; }
.hf-bar button { display: flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border: 0; border-radius: 13px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.hf-bar button:hover { background: var(--hf-fill); }
.hf-bar button:disabled { opacity: 0.4; cursor: default; }
.hf-bar i { width: 1px; height: 16px; background: var(--line); }
.hf-scroll { overflow-x: auto; scrollbar-width: none; border: 1px solid var(--line); border-radius: 10px; background: var(--hf-screen); width: max-content; max-width: 100%; }
.hf-scroll::-webkit-scrollbar { display: none; }
.hf-grid { width: max-content; min-width: 100%; }
.hf-r { display: flex; border-top: 1px solid var(--line); }
.hf-r:first-child { border-top: 0; }
.hf-r--h { background: var(--hf-fill); font-weight: 600; }
.hf-c {
  position: relative; flex: none; box-sizing: border-box; width: 150px; min-height: 41px; padding: 8px 10px; overflow: hidden;
  font-size: 17px; line-height: 24px; white-space: nowrap; text-align: left; cursor: text;
}
.hf-c--n { width: 80px; text-align: center; }
.hf-c--r { width: 120px; text-align: right; }
.hf-c--x { width: 130px; }
.hf-c:focus, .hf-c.is-edit { outline: none; }
.hf-c:focus::after, .hf-c.is-edit::after { content: ""; position: absolute; inset: 1px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px var(--brass); pointer-events: none; }
.hf-c input { all: unset; display: block; width: 100%; font: inherit; text-align: inherit; color: inherit; box-sizing: border-box; }
.hf-c .hf-mk { color: var(--muted); }
.hf-new { animation: hf-pop 0.45s var(--ease-spring) both; }
.hf-plus {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 22px; margin-top: 4px; padding: 0; border: 0; border-radius: 6px;
  background: var(--hf-fill); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 0.28s;
}
.hf-tbl:focus-within .hf-plus, .hf-tbl.is-ghost .hf-plus, .hf-plus:focus-visible { opacity: 1; }
@media (hover: none) { .hf-plus { opacity: 1; } }

/* ----------------------------------------------------------- wide cards */
.hf-card { background: var(--hf-card); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; font-family: "Karla", system-ui, sans-serif; color: var(--ink); }
.hf-card p { margin: 0; }
.hf-card ol, .hf-card ul { margin: 0; padding: 0; list-style: none; }
.hf-card button { font: inherit; color: inherit; }

/* history */
.hf-hist { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
@media (max-width: 700px) { .hf-hist { grid-template-columns: 1fr; } }
.hf-hist-list { padding: 22px 0 8px; border-right: 1px solid var(--line); }
@media (max-width: 700px) { .hf-hist-list { border-right: 0; border-bottom: 1px solid var(--line); } }
.hf-hist-h { padding: 0 20px; font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.3px; }
.hf-hist-note { display: flex; align-items: center; gap: 8px; padding: 10px 20px 14px; font-size: 14px; line-height: 20px; color: var(--muted); }
.hf-hist-note i { flex: none; width: 8px; height: 8px; border-radius: 4px; background: #A7BDA0; }
.hf-hist-note b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf-hist-note span { flex: none; margin-left: auto; }
.hf-vers { position: relative; border-top: 1px solid var(--line); }
.hf-vers button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 20px; border: 0; border-top: 1px solid transparent; background: transparent; text-align: left; cursor: pointer; transition: background-color 0.28s; }
.hf-vers li + li button { border-top-color: var(--line); }
.hf-vers button:hover { background: var(--hf-fill); }
.hf-vers button[aria-pressed="true"] { background: var(--sel); }
.hf-vers button i { flex: none; width: 8px; height: 8px; border-radius: 4px; background: var(--line); transition: background-color 0.28s, transform 0.45s var(--ease-spring); }
.hf-vers button[aria-pressed="true"] i { background: var(--brass); transform: scale(1.35); }
.hf-vers button span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hf-vers b { font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.2px; }
.hf-vers small { font-size: 13px; line-height: 18px; color: var(--muted); }
.hf-hist-view { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hf-scrub { display: flex; align-items: center; gap: 12px; }
.hf-scrub label { font-size: 13px; color: var(--muted); }
.hf-scrub input { flex: 1; min-width: 0; height: 44px; margin: 0; accent-color: var(--brass); cursor: ew-resize; background: transparent; }
.hf-scrub input:disabled { cursor: default; opacity: 0.6; }
.hf-hist-when { font-size: 13px; line-height: 18px; color: var(--muted); }
.hf-hist-doc { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); min-height: 214px; }
.hf-hist-t { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 8px !important; }
.hf-hist-doc li { display: flex; align-items: center; gap: 10px; min-height: 32px; margin-inline: -8px; padding: 0 8px; border-radius: 6px; font-size: 16px; transition: background-color 0.28s; }
.hf-hist-doc li.is-add { background: var(--hf-add); animation: hf-pop 0.45s var(--ease-spring) both; }
.hf-hist-doc li.is-done { color: var(--muted); }
.hf-hist-doc li.is-gone { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.hf-box { flex: none; width: 18px; height: 18px; border: 1.5px solid var(--muted); border-radius: 6px; position: relative; }
.is-done .hf-box { background: var(--brass); border-color: var(--brass); }
.is-done .hf-box::after { content: ""; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: solid #1B2A41; border-width: 0 2px 2px 0; transform: rotate(40deg); }
.is-gone .hf-box { opacity: 0.5; }
.hf-hist-act { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.hf-hist-act span { font-size: 13px; line-height: 18px; color: var(--muted); }
.hf-restore { min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: var(--brass); color: #1B2A41; font-size: 15px !important; font-weight: 700; cursor: pointer; transition: transform 0.28s var(--ease-spring); }
.hf-restore:active { transform: scale(0.97); }
.hf-restore:disabled { opacity: 0.7; cursor: default; }

/* locked note */
.hf-lockcard { position: relative; padding: 18px 0 8px; min-height: 360px; }
.hf-lhead { display: flex; align-items: center; justify-content: space-between; padding: 0 18px 12px; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.5px; }
.hf-lhead span { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.hf-lhead svg { color: var(--brass-text); }
.hf-nrows { display: flex; flex-direction: column; }
.hf-nrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 16px 18px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; box-sizing: border-box; transition: background-color 0.28s; }
.hf-nrow:first-child { border-top: 0; }
.hf-nrow i { flex: none; width: 8px; height: 8px; border-radius: 4px; }
.hf-nrow .d1 { background: #D9C48C; } .hf-nrow .d2 { background: #A3B6C9; } .hf-nrow .d3 { background: #C9A0A0; }
.hf-nrow > span { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hf-nrow b { display: flex; align-items: center; gap: 6px; font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf-nrow small { font-size: 13px; line-height: 18px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hf-nrow em { flex: none; align-self: flex-start; font-style: normal; font-size: 12px; line-height: 20px; color: var(--muted); }
.hf-nrow--lock { cursor: pointer; }
.hf-nrow--lock:hover, .hf-nrow--lock.is-tap { background: var(--hf-fill); }
.hf-lk { flex: none; color: var(--brass-text); }
.hf-shackle { transform-box: fill-box; transform-origin: 0 100%; transition: transform 0.45s var(--ease-spring); }
.is-open .hf-shackle { transform: translateY(-2.5px) rotate(-24deg); }
.hf-lockcard small[data-lockprev] { transition: opacity 0.28s; }
.hf-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 24px 28px;
  background: var(--paper); border-radius: 20px 20px 0 0; box-shadow: 0 -2px 6px rgba(27, 42, 65, 0.1), 0 -24px 56px -18px rgba(27, 42, 65, 0.45);
  transform: translateY(105%); visibility: hidden; transition: transform 0.45s var(--ease-spring), visibility 0s 0.45s;
}
.hf-sheet.is-up { transform: none; visibility: visible; transition-delay: 0s; }
.hf-sheet p { font-size: 15px; font-weight: 600; }
.hf-fid { color: var(--brass-text); }
.hf-fid path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.hf-fid-ok { opacity: 0; }
.hf-sheet.is-scan .hf-fid path:not(.hf-fid-ok) { animation: hf-draw 0.9s ease both; }
.hf-sheet.is-scan .hf-fid path:nth-child(2) { animation-delay: 0.15s; }
.hf-sheet.is-scan .hf-fid path:nth-child(3) { animation-delay: 0.3s; }
.hf-sheet.is-ok .hf-fid path:not(.hf-fid-ok) { opacity: 0; transition: opacity 0.2s; }
.hf-sheet.is-ok .hf-fid-ok { opacity: 1; animation: hf-draw 0.45s ease both; }
@keyframes hf-draw { from { stroke-dashoffset: 1; } }

@media (prefers-reduced-motion: reduce) {
  .hf *, .hf *::before, .hf *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}
.hf-pill[hidden] { display: none; }
.hf-hist-doc { min-height: 240px; }
.hf-mk { color: var(--muted); }

/* the version scrubber: a hairline track and a brass thumb */
.hf-scrub input { -webkit-appearance: none; appearance: none; }
.hf-scrub input::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
.hf-scrub input::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.hf-scrub input::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: var(--brass); border: 3px solid var(--raised); box-shadow: 0 1px 4px rgba(27, 42, 65, 0.35); }
.hf-scrub input::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brass); border: 3px solid var(--raised); box-shadow: 0 1px 4px rgba(27, 42, 65, 0.35); }

/* Hover, for the controls that had none. */
@media (hover: hover) {
  .hf-fmt:not([aria-pressed="true"]):hover { background: var(--hf-fill); }
  .hf-chk:not([aria-checked="true"]):hover { border-color: var(--ink); }
  .hf-plus:hover { color: var(--ink); }
  .hf-restore:not(:disabled):hover { background: #C4A06A; }
}
@media (hover: hover) and (prefers-color-scheme: dark) { .hf-restore:not(:disabled):hover { background: #D4B27A; } }
