/* Someday card builder — self-contained styles (no inline styles in markup). */

:root {
  color-scheme: dark;
  --bg: #131110;
  --bg-soft: #191614;
  --panel: #1c1815;
  --panel-2: #221d19;
  --ink: #f4ede2;
  --muted: #a89d8f;
  --faint: #8c8276;
  --line: rgba(244, 237, 226, 0.14);
  --line-soft: rgba(244, 237, 226, 0.08);
  --gold: #c8a06b;
  --gold-deep: #a4804f;
  --warn: #e0a98d;
  --ok: #cfc09a;
  --paper: #f6f0e7;
  --radius: 20px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Hoefler Text", Georgia, "Noto Serif", "Times New Roman", serif;
  --sans: "Helvetica Neue", "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background:
    radial-gradient(1100px 620px at 18% -8%, rgba(200, 160, 107, 0.11), transparent 62%),
    radial-gradient(900px 700px at 100% 12%, rgba(200, 160, 107, 0.05), transparent 64%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(200, 160, 107, 0.28);
  color: #fff;
}

a {
  color: var(--gold);
}

button,
a,
summary,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 40px);
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--paper);
  color: #1a1714;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  margin: 0;
  padding: 12px 20px;
  background: #2a2118;
  color: #f4ede2;
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Top bar ---------- */

.topbar {
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.wordmark {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ink);
}

.wordmark-sep {
  color: var(--gold-deep);
}

.topbar-note {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--faint);
}

/* ---------- Hero ---------- */

.hero {
  max-width: 780px;
  padding: 24px 0 20px;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.35rem, 5.4vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lede {
  display: none;
  max-width: 640px;
  margin: 20px 0 0;
  font-size: clamp(0.98rem, 1.6vw, 1.08rem);
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- Workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding-bottom: 24px;
}

.starter {
  order: 1;
}

.preview {
  order: 2;
}

.editor {
  order: 3;
}

#preview,
#editor {
  scroll-margin-top: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: linear-gradient(180deg, #1e1a16 0%, #181513 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.jump-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: nowrap;
}

.panel-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.panel-sub {
  margin: 8px 0 4px;
  font-size: 0.8rem;
  color: var(--faint);
}

.group {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.group:first-of-type {
  border-top: 0;
  padding-top: 16px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.group h3 {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.count,
.optional {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.group-hint {
  margin: 7px 0 14px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------- Items ---------- */

.item-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.item-index {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold-deep);
}

.item-input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #14110f;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
}

.item-remove {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--faint);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.item-remove:hover {
  border-color: var(--line);
  color: var(--ink);
}

.item-remove:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.add-item {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.84rem;
  cursor: pointer;
}

.add-item:hover:not(:disabled) {
  border-color: var(--gold-deep);
  color: var(--gold);
}

.add-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Starter ---------- */

.starter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.btn-draw {
  flex: 1 1 200px;
  min-height: 48px;
  font-size: 0.9rem;
}

.starter-note {
  margin: 10px 0 0;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------- Fields ---------- */

.field {
  display: block;
  min-width: 0;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #14110f;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

.field textarea {
  resize: vertical;
  min-height: 74px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #857c70;
}

.field input:focus,
.field textarea:focus,
.item-input:focus {
  outline: none;
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(200, 160, 107, 0.18);
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.field-full {
  margin-top: 12px;
}

.mini-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(200, 160, 107, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.mini-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(200, 160, 107, 0.08);
}

.mini-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.locate-status {
  margin: 12px 0 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--faint);
}

.locate-status[data-tone="ok"] {
  color: var(--ok);
}

.locate-status[data-tone="warn"] {
  color: var(--warn);
}

.locate-status[data-tone="busy"]::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--gold);
  vertical-align: 1px;
  animation: pulse 1.1s ease-in-out infinite;
}

.credit {
  margin: 10px 0 0;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: #8a8074;
}

/* ---------- Generate ---------- */

.generate {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #e2c69d 0%, #c9a26a 100%);
  color: #1d1712;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ecd5b3 0%, #d4ae77 100%);
}

.btn-secondary {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--gold-deep);
  color: var(--gold);
}

.btn-ghost {
  border-color: var(--line-soft);
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.btn-generate {
  width: 100%;
  min-height: 54px;
  font-size: 0.96rem;
}

.generate-note {
  margin: 10px 0 0;
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--faint);
}

.editor-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(224, 169, 141, 0.35);
  border-radius: 9px;
  background: rgba(224, 169, 141, 0.08);
  color: var(--warn);
  font-size: 0.8rem;
}

.clear-draft {
  min-height: 44px;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8a8175;
  font-family: var(--sans);
  font-size: 0.72rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.clear-draft:hover {
  color: var(--muted);
}

/* ---------- Preview ---------- */

.preview {
  position: static;
  min-width: 0;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.preview-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.preview-meta {
  margin: 0 0 12px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.card-mount {
  padding: clamp(8px, 1.4vw, 14px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 70%),
    rgba(255, 255, 255, 0.025);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.5);
}

#card-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: var(--paper);
}

.card-open {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.card-open:hover {
  border-color: var(--gold-deep);
  color: var(--gold);
}

.jump-link:active {
  opacity: 0.6;
}

.mobile-tip {
  margin: 8px 0 0;
  font-size: 0.68rem;
  line-height: 1.55;
  color: var(--faint);
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.actions .btn {
  width: 100%;
}

.actions .btn-ghost {
  grid-column: 1 / -1;
}

.status {
  margin: 12px 0 0;
  min-height: 22px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--faint);
}

.status[data-tone="ok"] {
  color: var(--ok);
}

.status[data-tone="warn"] {
  color: var(--warn);
}

.status[data-tone="error"] {
  color: #eda48d;
}

.fineprint {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--faint);
}

.fineprint summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.fineprint summary:hover {
  color: var(--gold);
}

.fineprint[open] summary {
  margin-bottom: 10px;
}

.fineprint ul {
  margin: 0;
  padding-left: 18px;
}

.fineprint li {
  margin-bottom: 8px;
}

.fineprint strong {
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Notes ---------- */

.notes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--line-soft);
}

.note h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.note p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- Footer ---------- */

.footer {
  margin-top: clamp(48px, 7vw, 76px);
  border-top: 1px solid var(--line-soft);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 22px;
  padding-bottom: 26px;
  font-size: 0.7rem;
  color: #8a8175;
}

.footer-inner p {
  margin: 0;
}

/* ---------- Focus ---------- */

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.field input:focus-visible,
.field textarea:focus-visible,
.item-input:focus-visible {
  outline: none;
}

/* ---------- Motion ---------- */

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive: mobile first ---------- */

.topbar-note {
  display: none;
}

.hero h1 {
  font-size: clamp(2.1rem, 9.6vw, 2.8rem);
}

.footer-inner {
  display: block;
}

.footer-inner p + p {
  margin-top: 6px;
}

@media (min-width: 561px) {
  .topbar-note {
    display: block;
  }

  .lede {
    display: block;
  }

  .hero {
    padding: clamp(36px, 6vw, 58px) 0 clamp(24px, 4vw, 40px);
  }

  .hero h1 {
    font-size: clamp(2.35rem, 5.4vw, 4rem);
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  }

  .actions .btn-ghost {
    grid-column: 1 / -1;
  }

  .panel {
    padding: clamp(20px, 3vw, 28px);
    border-radius: 22px;
  }

  .mobile-tip {
    display: none;
  }

  .footer-inner {
    display: flex;
  }

  .footer-inner p + p {
    margin-top: 0;
  }
}

@media (min-width: 941px) {
  .workspace {
    grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
    grid-template-areas:
      "starter preview"
      "editor preview";
    column-gap: 56px;
    row-gap: 20px;
  }

  .starter {
    grid-area: starter;
  }

  .editor {
    grid-area: editor;
  }

  .preview {
    grid-area: preview;
    position: sticky;
    top: 24px;
  }

  .panel {
    border-radius: 24px;
    padding: 28px;
  }

  .jump-link {
    display: none;
  }

  .notes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 36px;
    margin-top: 72px;
    padding-top: 34px;
  }
}

/* ---------- Touch feedback ---------- */

.btn,
.mini-btn,
.add-item,
.item-remove,
.card-open,
.clear-draft,
.fineprint summary {
  transition: transform 0.09s ease, background-color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.btn:active:not(:disabled),
.mini-btn:active:not(:disabled),
.add-item:active:not(:disabled),
.item-remove:active:not(:disabled),
.card-open:active,
.clear-draft:active,
.fineprint summary:active {
  transform: scale(0.975);
}

.fineprint summary {
  padding: 11px 0;
  min-height: 44px;
}
