/* ══════════════════════════════════════════════
   NOTE CARD
   Two things share this file: the composer (a
   visitor writes a note) and the published card
   (an approved note on the wall). Both use the
   same shell — border/radius/shadow/padding — so
   they read as one family.

   Composer states (one data-state attribute, set
   by note-card.js's setState()):
     default | expanded | ready | sending | sent | error
   Hover/pressed/focus are plain CSS pseudo-classes,
   not states — they're not part of the data model.

   Figma source: Website Design System, node 236:678
   (component set) / 236:84 (page layout).
══════════════════════════════════════════════ */

.note-card {
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  /* Shadow/Card Rest — same value as .float-card (style.css), used
     intentionally instead of the Figma-literal 0 2px 8px so this stays
     inside the one shadow language the rest of the site already uses. */
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease;
  font-family: var(--font);
}

/* Closed card only — the 16px shadow blur reads as too heavy/soft on
   the small trigger button. Every open state (expanded/ready/sending/
   sent/error) and the published card keep the base shadow above. */
.note-card[data-state="default"] {
  box-shadow: none;
}

/* Shadow/Card Hover — "featured/work-card," documented in
   design-system.html §03 — gives the closed card a real lift on
   hover/keyboard-focus instead of rest and hover looking identical.
   :focus-within (not :focus-visible on this element) because focus
   actually lands on the inner .note-card__trigger button. */
.note-card[data-state="default"]:hover,
.note-card[data-state="default"]:focus-within {
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.07);
}

.note-card__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Trigger (persistent header) ────────────────
   Always visible, in every state — it's the card's header, not a
   button that gets swapped out for the form. That's the whole point:
   nothing ever needs to hide or reappear in sync with the panel
   below it, which is what every previous animation attempt kept
   getting wrong one way or another. Clicking it opens when closed;
   while open it defers to the same empty-fields rule as Escape (see
   note-card.js), so it can't discard typed text either.
   "+" icon is a CSS mask of icons/plus.svg, not an <img> — a mask
   only reads the SVG's alpha shape, so background-color drives the
   color regardless of the fill baked into the source file. That's
   what lets one asset serve both the muted and ink states; the same
   mask rotates 45° into an "×" to signal open/close. ── */
.note-card__trigger {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
}

.note-card__icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  background-color: var(--color-ink-muted);
  -webkit-mask: url("icons/plus.svg") center / contain no-repeat;
  mask: url("icons/plus.svg") center / contain no-repeat;
  transition:
    background-color 0.2s ease,
    transform 0.25s ease;
}
.note-card:not([data-state="default"]) .note-card__icon {
  transform: rotate(45deg);
}

.note-card__trigger-label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  /* --color-ink-muted is ~3.5:1 on white — fails AA for this resting
     label (it's real, permanent text, not a placeholder/disabled
     hint). --color-ink-soft (~7.5:1) keeps the same "quieter than
     active" read while staying readable. */
  color: var(--color-ink-soft);
  transition: color 0.2s ease;
}

.note-card__trigger:hover .note-card__icon,
.note-card__trigger:focus-visible .note-card__icon {
  background-color: var(--color-ink);
}
.note-card__trigger:hover .note-card__trigger-label,
.note-card__trigger:focus-visible .note-card__trigger-label {
  color: var(--color-ink);
}
.note-card__trigger:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: -2px;
  border-radius: 10px;
}

/* ── Panel (expanded form / sent message) ──────
   grid-template-rows: 0fr → 1fr, same technique .faq-item__body
   (questions.css) uses — the browser interpolates the row size
   itself, no JS height math, nothing waiting on a transition event.
   This part was never what broke across the earlier attempts; the
   trigger now being a persistent header (above) is what fixes it —
   there's no second element whose own visibility needs to stay in
   sync with this one. .note-card__panel-inner's opacity/transform
   fade keeps content from popping in/out abruptly. ── */
.note-card__panel {
  display: grid;
  grid-template-rows: 0fr;
  /* Pin the single column to the card's width. Left to the default,
     the column grows to fit the widest child — Cloudflare's 300px
     Turnstile widget made it wider than the card, so the form, Post
     button and privacy line were laid out too wide and clipped. */
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  transition: grid-template-rows 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}
.note-card:not([data-state="default"]) .note-card__panel {
  grid-template-rows: 1fr;
}

.note-card__panel-inner {
  min-height: 0;
  opacity: 0;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  transform: translateY(-4px);
}
.note-card:not([data-state="default"]) .note-card__panel-inner {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.1s;
}

.note-card__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.note-card[data-state="sent"] .note-card__form {
  display: none;
}

.note-card__body {
  display: block;
  width: 100%;
  height: 84px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-ink);
  padding: 0;
}
.note-card__body::placeholder {
  color: var(--color-ink-muted);
}

.note-card__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}

.note-card__name {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-ink);
  padding: 0;
}
.note-card__name::placeholder {
  color: var(--color-ink-muted);
}

/* Post button — full glossy .featured-card__cta look is the default
   (apply that class directly in markup); this knocks it back to a
   flat, muted, non-glass look while the form is open-but-invalid.
   Still a real, clickable <button> — never `disabled` — so an early
   click can redirect focus to whichever field needs attention. */
.note-card[data-state="expanded"] .note-card__post {
  background: var(--color-bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-color: var(--color-border);
  color: var(--color-ink-muted);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  transform: none;
}
.note-card[data-state="expanded"] .note-card__post::before {
  content: none;
}
.note-card[data-state="expanded"] .note-card__post:hover {
  transform: none;
  background: var(--color-bg);
  border-color: var(--color-border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}
.note-card__post:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 2px;
}

/* Privacy line under the form — what's stored and that notes are
   reviewed. --color-ink-soft, not -muted: it's real text a visitor
   needs to read, and -muted fails AA at this size. */
.note-card__privacy {
  margin: 0;
  padding: 0 16px 16px;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--color-ink-soft);
}
.note-card[data-state="sent"] .note-card__privacy {
  display: none;
}

/* Turnstile spam check (live composer only). Collapsed to nothing
   while Cloudflare decides silently; note-card.js sets
   data-visible only when it actually needs a click. */
.note-card__turnstile {
  height: 0;
  overflow: hidden;
}
.note-card__turnstile[data-visible="true"] {
  height: auto;
  padding: 0 16px 16px;
}
.note-card[data-state="sent"] .note-card__turnstile {
  display: none;
}

.note-card__sent {
  display: none;
  margin: 0;
  padding: 16px;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-ink);
}
.note-card[data-state="sent"] .note-card__sent {
  display: block;
}

.note-card__status {
  margin: 0;
  padding: 0 16px 16px;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--color-ink-muted);
  min-height: 0;
}
.note-card[data-state="error"] .note-card__status {
  color: var(--color-error);
}
.note-card__status:empty {
  padding: 0;
}

/* ── Published note card ───────────────────────
   Built by renderNoteCard() in note-card.js. Hugs its content —
   no fixed heights, no clamping. ── */
.note-card--published {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.note-card__published-body {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-ink);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.note-card__published-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}

.note-card__published-name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

/* Reveals on hover/focus (desktop) — same max-width/opacity reveal
   technique as .nav__plus-label in style.css, reused rather than
   reinvented. Always visible on touch (no hover to reveal it with). */
.note-card__published-date {
  flex-shrink: 0;
  max-width: 0;
  margin-left: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
  transition:
    max-width 0.3s ease,
    opacity 0.25s ease,
    margin-left 0.3s ease;
}
.note-card--published:hover .note-card__published-date,
.note-card--published:focus-visible .note-card__published-date {
  max-width: 160px;
  opacity: 1;
  margin-left: auto;
}
.note-card--published:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 2px;
  border-radius: 10px;
}

@media (hover: none) {
  .note-card__published-date {
    max-width: none;
    opacity: 1;
    margin-left: auto;
    transition: none;
  }
}

/* ── Wall — the container multiple note cards live in ──
   The composer is always the first item; published cards join it as
   they're approved. Plain CSS multi-column: responsive for free, no
   JS balancing needed. Validated in the (now-deleted) notes-demo.html
   stress test before landing here. */
.notes-wall {
  column-count: 3;
  column-gap: 24px;
  max-width: 900px;
  margin: 0 auto;
}
.notes-wall > * {
  break-inside: avoid;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .notes-wall {
    column-count: 2;
  }
}
@media (max-width: 600px) {
  .notes-wall {
    column-count: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .note-card__panel,
  .note-card__panel-inner,
  .note-card__published-date,
  .note-card__icon,
  .note-card__trigger-label {
    transition: none;
  }
}
