/* Alfies Idea Factory
   Layout: a ruled notebook page in pale yellow; filters and four idea cards sit on the ruling,
   with hand-drawn coral doodles in the margins. The full brief stacks white sections down the same page. */
:root {
  --ink: #1c1917;
  --text: #292524;
  --soft: #57534e;
  --muted: #78716c;
  --faint: #a8a29e;
  --paper: #ffffff;
  --rule: rgba(150, 125, 40, 0.14);
  --line: #ece7da;
  --hover: #fdf4d3;
  --amber-ink: #92400e;
  --amber-soft: #fef3c7;
  --amber-edge: #f2c14e;
  --orange: #fb923c;
  --doodle: #ee8b5e;
  --doodle-fill: #fde3d3;
  --coral-ink: #c2410c;
  --peach: #fed7aa;
  --mint: #34d399;
  --mint-ink: #064e3b;
  --box-blue: #ebeee9;
  --box-mint: #d7f1e3;
  --wash: linear-gradient(180deg, #fffbe8 0%, #fef7d9 55%, #fdf1c6 100%);
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background-color: #fef8dd;
  background-image: repeating-linear-gradient(180deg, transparent 0 47px, var(--rule) 47px 48px), var(--wash);
  background-attachment: scroll;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ig-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.ig-top { position: sticky; top: 0; z-index: 20; background: rgba(255, 251, 232, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.ig-top-in { display: flex; align-items: center; gap: 28px; max-width: 1280px; height: 56px; margin: 0 auto; padding-inline: max(16px, 32px); }
.ig-brand { font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.ig-nav { display: flex; gap: 6px; }
.ig-menu { position: relative; }
.ig-navbtn { padding: 6px 12px; border-radius: var(--r); font-size: 14.5px; color: var(--text); transition: background 0.15s, color 0.15s; }
.ig-navbtn[aria-expanded="true"] { background: rgba(150, 110, 10, 0.1); }
.ig-pop { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: 0 16px 40px rgba(80, 60, 20, 0.16); animation: ig-pop 0.16s ease-out; }
.ig-pop-wide { min-width: 280px; }
@keyframes ig-pop { from { opacity: 0; transform: translateY(-4px); } }
.ig-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 6px; font-size: 14px; text-align: left; color: var(--text); text-decoration: none; }
.ig-item:hover { background: var(--hover); }
.ig-item small { display: block; margin-top: 1px; font-size: 12.5px; color: var(--muted); }
.ig-item kbd { padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; font: 12px var(--mono); color: var(--muted); }
.ig-radio, .ig-check { padding-left: 32px; position: relative; justify-content: flex-start; }
.ig-radio::before, .ig-check::before { content: ""; position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border: 1.5px solid var(--faint); border-radius: 50%; }
.ig-check::before { border-radius: 4px; }
.ig-radio[aria-checked="true"]::before { border-color: var(--ink); background: radial-gradient(circle, var(--ink) 0 3.5px, transparent 4px); }
.ig-check[aria-checked="true"]::before { border-color: var(--ink); background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 7.5l2.5 2.5L11 4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat; }
.ig-pop-h { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ig-recent .ig-item { display: block; }
.ig-recent .ig-item span { display: block; font-size: 12.5px; color: var(--muted); }
.ig-recent .ig-empty { padding: 4px 10px 8px; font-size: 13px; color: var(--faint); }
.ig-pop hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--line); }

/* generator */
.ig-main { flex: 1; width: 100%; }
.ig-view { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.ig-view:not([hidden]) { animation: ig-in 0.32s ease-out; }
@keyframes ig-in { from { opacity: 0; transform: translateY(8px); } }
.ig-gen { padding-top: clamp(96px, 26vh, 274px); padding-bottom: 120px; }
.ig-stage { position: relative; max-width: 1168px; margin: 0 auto; }
.ig-filters { display: flex; flex-direction: column; gap: 14px; }
.ig-row { display: flex; align-items: flex-start; gap: 16px; }
.ig-flabel { flex: none; width: 74px; padding-top: 7px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); }
.ig-chips { display: flex; flex-wrap: wrap; gap: 10px; min-width: 0; }
.ig-chip { padding: 6px 14px; border: 1px solid #ebe5d6; border-radius: 4px; background: rgba(255, 255, 255, 0.92); font-size: 13px; color: #44403c; white-space: nowrap; transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.12s; }
.ig-chip:active { transform: scale(0.97); }
.ig-chip[aria-checked="true"] { border-color: var(--amber-edge); background: var(--amber-soft); color: var(--amber-ink); }

.ig-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px; margin-top: 30px; }
.ig-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ig-card label { font-size: 14.5px; color: var(--ink); }
.ig-box { position: relative; border: 1.5px solid transparent; border-radius: 14px; background: var(--paper); box-shadow: 0 1px 2px rgba(80, 60, 20, 0.05), 0 6px 18px rgba(80, 60, 20, 0.07); transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s; }
.ig-box:focus-within { border-color: var(--amber-edge); box-shadow: 0 0 0 4px rgba(242, 193, 78, 0.28), 0 6px 18px rgba(80, 60, 20, 0.07); }
.ig-card.locked .ig-box { border-color: var(--amber-edge); }
.ig-box textarea { display: block; width: 100%; min-height: 110px; padding: 16px 44px 16px 16px; border: 0; border-radius: 14px; background: transparent; font: inherit; font-size: 15.5px; line-height: 1.4; color: var(--text); resize: vertical; outline: none; }
.ig-card.spin textarea { color: var(--faint); filter: blur(0.4px); animation: ig-spin 0.12s linear infinite; }
@keyframes ig-spin { 0% { transform: translateY(-2px); } 50% { transform: translateY(2px); } 100% { transform: translateY(-2px); } }
.ig-card.land .ig-box { animation: ig-land 0.42s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes ig-land { 0% { transform: translateY(5px) scale(0.985); } 100% { transform: none; } }
.ig-lock { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #c4bdb3; transition: color 0.15s, background 0.15s; }
.ig-lock svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ig-lock .ig-shackle { transform: translate(5px, 0) rotate(0); transform-origin: 16px 11px; transition: transform 0.2s; }
.ig-lock[aria-pressed="true"] { color: var(--amber-ink); background: var(--amber-soft); }
.ig-lock[aria-pressed="true"] .ig-shackle { transform: none; }
.ig-lock:not([aria-pressed="true"]) .ig-shackle { transform: rotate(-28deg); }

.ig-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 56px; }
.ig-tip { margin-right: auto; font-size: 13px; color: var(--muted); }
.ig-regen, .ig-full { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 40px; padding: 0 24px; border-radius: 8px; font-size: 15px; transition: transform 0.12s, background-color 0.15s, color 0.15s, box-shadow 0.15s; }
.ig-regen { background: var(--orange); color: var(--ink); box-shadow: 0 6px 16px rgba(194, 65, 12, 0.24); }
.ig-regen svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.5s; }
.ig-regen.busy svg { transform: rotate(360deg); }
.ig-full { background: var(--peach); color: var(--text); box-shadow: 0 2px 4px rgba(80, 60, 20, 0.06), 0 8px 20px rgba(120, 70, 20, 0.16); }
.ig-regen:active, .ig-full:active { transform: scale(0.97); }

/* doodles */
.ig-doodle { position: absolute; fill: none; stroke: var(--doodle); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
body.no-doodles .ig-doodle { display: none; }
.d-stars { left: 28px; top: -76px; width: 120px; }
.d-stars path, .b-stars path { fill: var(--doodle-fill); }
.d-stars path:last-child, .b-stars path:last-child { animation: ig-twinkle 3.2s ease-in-out infinite; transform-origin: 83px 52px; transform-box: view-box; }
@keyframes ig-twinkle { 50% { transform: rotate(14deg) scale(1.08); } }
.d-burst { left: 522px; top: -86px; width: 140px; }
.d-burst circle { fill: var(--doodle); stroke: none; }
.d-squiggle { left: 548px; top: 246px; width: 146px; }
.d-check { width: 58px; }
.d-check-1 { left: 66px; top: 432px; }
.d-check-2 { left: 66px; top: 542px; }
.ig-doodle.pop path, .ig-doodle.pop circle { animation: ig-pop-ray 0.6s ease-out; transform-box: fill-box; transform-origin: center bottom; }
@keyframes ig-pop-ray { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: none; } }
.d-squiggle path, .d-check path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.ig-doodle.draw path { animation: ig-draw 0.9s ease-out; }
@keyframes ig-draw { from { stroke-dashoffset: 1; } }
.d-check rect { stroke-width: 2.6; }

/* full brief */
.ig-brief { padding-top: 40px; padding-bottom: 96px; }
.ig-bwrap { position: relative; max-width: 980px; margin: 0 auto; }
.ig-back { display: inline-flex; gap: 6px; margin-bottom: 26px; padding: 4px 0; font-size: 13.5px; color: var(--soft); }
.ig-bhead { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 34px; border-bottom: 1px solid rgba(150, 125, 40, 0.2); }
.ig-eyebrow { font-size: 12.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); }
.ig-btitle { margin-top: 18px; font-size: clamp(28px, 4vw, 36px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); text-wrap: balance; }
.ig-bsub { margin-top: 10px; font-size: 14.5px; color: var(--soft); }
.ig-bactions { display: flex; flex-wrap: wrap; gap: 12px; flex: none; }
.ig-ghost, .ig-green { height: 32px; padding: 0 14px; border-radius: 4px; font-size: 13px; font-weight: 600; transition: transform 0.12s, background-color 0.15s, border-color 0.15s, color 0.15s; }
.ig-ghost { border: 1px solid #e7e0cf; background: var(--paper); color: var(--ink); }
.ig-green { border: 1px solid var(--mint); background: var(--mint); color: var(--mint-ink); }
.ig-ghost:active, .ig-green:active { transform: scale(0.97); }
@media (hover: hover) {
  .ig-navbtn:hover, .ig-chip:hover, .ig-regen:hover, .ig-full:hover, .ig-ghost:hover, .ig-green:hover { border-color: #000; background: #000; color: #fff; }
  .ig-regen:hover, .ig-full:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22); }
  .ig-lock:hover { color: #000; background: var(--amber-soft); }
  .ig-back:hover { color: #000; }
}
.ig-brief-body { display: flex; flex-direction: column; gap: 26px; margin-top: 34px; }
.ig-brief-body.swap { animation: ig-in 0.35s ease-out; }
.ig-sum { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.ig-sum div { min-width: 0; padding: 12px 12px 13px; border-radius: 8px; background: var(--paper); }
.ig-sum dt { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ig-sum dd { margin-top: 3px; font-size: 14.5px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.ig-sec { padding: 32px; border-radius: 10px; background: var(--paper); }
.ig-sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.ig-sec-h h2 { font-size: 16px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink); }
.ig-sec-h span { font-size: 11.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
.ig-over p { font-size: 16px; line-height: 1.55; color: var(--soft); }
.ig-over p + p { margin-top: 14px; }
.ig-over b { font-weight: 700; color: var(--ink); }
.ig-two { display: grid; grid-template-columns: 1fr 1fr; gap: 30px 44px; padding: 0 16px; }
.ig-two h3 { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.ig-two p { margin-top: 8px; font-size: 14px; line-height: 1.65; color: var(--soft); }
.ig-wild { grid-column: 1 / -1; display: flex; gap: 12px; align-items: baseline; padding: 12px 16px; border: 1.5px dashed var(--doodle); border-radius: 8px; background: #fff5ec; font-size: 14px; color: var(--text); }
.ig-wild b { flex: none; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--coral-ink); }
.ig-dels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.ig-del { padding: 16px 16px 18px; border-radius: 6px; background: var(--box-blue); }
.ig-del:last-child { background: var(--box-mint); }
.ig-del h3 { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.ig-del ul, .ig-guards { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ig-del li, .ig-guards li { position: relative; padding-left: 18px; font-size: 14px; line-height: 1.45; color: var(--soft); }
.ig-del li::before, .ig-guards li::before { content: ""; position: absolute; left: 4px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.ig-persona { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 20px; align-items: start; }
.ig-arch { padding: 18px 18px 20px; border-radius: 6px; background: var(--box-mint); }
.ig-arch small { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.ig-arch strong { display: block; margin-top: 8px; font-size: 19px; line-height: 1.3; color: var(--ink); text-wrap: balance; }
.ig-arch span { display: block; margin-top: 10px; font-size: 12.5px; color: var(--soft); }
.ig-persona p { font-size: 14.5px; line-height: 1.6; color: var(--soft); }
.ig-persona p + p { margin-top: 12px; }
.ig-voice { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 40px; }
.ig-lbl { font-size: 11.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ig-tones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.ig-tones span { padding: 4px 10px; border-radius: 4px; background: #f5f2ea; font-size: 13px; color: #44403c; }
.ig-note { margin-top: 14px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.ig-guards li { font-size: 13.5px; }
.b-stars { left: -84px; top: 34px; width: 116px; }
.b-burst { left: 430px; top: -6px; width: 118px; }
.b-smile { right: -46px; top: 470px; width: 46px; }
.b-check-1 { left: -84px; bottom: 150px; }
.b-check-2 { left: -84px; bottom: 60px; }
.ig-brief .d-check path { stroke-dashoffset: 1; }
.ig-brief.ticked .d-check path { animation: ig-tick 0.7s ease-out forwards; }
@keyframes ig-tick { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.ig-brief.ticked .b-check-2 path { animation-delay: 0.35s; }

/* footer and toast */
.ig-foot { padding: 0 16px 28px; text-align: center; font-size: 12.5px; color: var(--muted); }
.ig-toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); z-index: 40; padding: 10px 16px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; opacity: 0; visibility: hidden; transform: translate(-50%, 10px); transition: opacity 0.2s, transform 0.25s, visibility 0.2s; }
.ig-toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* narrower screens */
@media (max-width: 1100px) {
  .d-burst, .d-squiggle { display: none; }
  .b-stars, .b-check-1, .b-check-2, .b-smile { display: none; }
}
@media (max-width: 960px) {
  .ig-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .ig-sum { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .d-check { display: none; }
  .b-burst { display: none; }
}
@media (max-width: 760px) {
  .ig-top-in { flex-wrap: wrap; height: auto; padding-block: 10px; gap: 6px 16px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
  .ig-top-in { position: relative; }
  .ig-nav { order: 3; width: 100%; margin-left: -12px; }
  .ig-menu { position: static; }
  .ig-pop, .ig-pop-wide { left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); top: calc(100% + 4px); min-width: 0; }
  .ig-gen { padding-top: 64px; }
  .ig-row { flex-direction: column; gap: 8px; }
  .ig-flabel { width: auto; padding-top: 0; }
  .ig-chips { gap: 8px; }
  .ig-bhead { flex-direction: column; align-items: flex-start; }
  .ig-two, .ig-voice, .ig-persona, .ig-dels { grid-template-columns: 1fr; }
  .ig-two { padding: 0; }
  .ig-sec { padding: 22px 18px; }
  .ig-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .d-stars { left: auto; right: 0; top: -60px; width: 84px; }
}
@media (max-width: 560px) {
  .ig-cards { grid-template-columns: 1fr; }
  .ig-box textarea { min-height: 84px; }
  .ig-actions { flex-wrap: wrap; margin-top: 32px; }
  .ig-tip { width: 100%; }
  .ig-regen, .ig-full { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ig-brief .d-check path { stroke-dashoffset: 0; }
}
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; }
body.no-anim .ig-brief .d-check path { stroke-dashoffset: 0; }

/* print: just the brief */
@media print {
  body { background: #fff; display: block; }
  .ig-top, .ig-foot, .ig-back, .ig-bactions, .ig-doodle, .ig-toast, #v-cards { display: none !important; }
  #v-brief { display: block !important; padding: 0; }
  .ig-sec, .ig-sum div { border: 1px solid #e7e0cf; break-inside: avoid; }
  .ig-brief-body { gap: 14px; margin-top: 18px; }
  .ig-bhead { padding-bottom: 14px; }
}
