/* Comic Maker (comic-maker/): the strip row, the panel being edited, the selection bar and the
   tray of things to add. Loaded after styles.css. The lettering fonts are the same OFL files the
   comic library uses (copied in by build.mjs), so what you see is what gets downloaded. */
@font-face { font-family: 'Maker Bangers'; src: url('fonts/Bangers-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'Maker Fredoka'; src: url('fonts/Fredoka-Variable.ttf') format('truetype'); font-weight: 300 700; font-display: block; }

.maker-page { padding: 32px 0 64px; }
.maker-head { margin-bottom: 20px; }
.maker-lede { max-width: 40rem; margin: 6px auto 0; color: var(--muted); }

/* ---------- ideas ---------- */
.ideas { margin-bottom: 24px; }
.ideas__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
.ideas__title { font-size: 1.35rem; margin: 0; }
.ideas__head p { margin: 0; color: var(--muted); }
.ideas__list {
  list-style: none; margin: 0; padding: 4px 4px 14px; display: grid; grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 300px); gap: 14px; overflow-x: auto; scroll-snap-type: x proximity;
}
.idea {
  scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px;
  background: var(--card); border: var(--outline); border-radius: 14px; box-shadow: 3px 4px 0 var(--ink);
}
.idea h3 { margin: 0; font-size: 1.1rem; }
.idea p { margin: 0; font-size: .95rem; color: var(--muted); }
.idea ol { margin: 0; padding-left: 1.2em; font-size: .9rem; }
.idea .btn { margin-top: auto; align-self: flex-start; }
.ideas__more { display: none; }
@media (min-width: 900px) {
  .ideas__list { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); grid-auto-columns: auto; overflow: visible; }
  .ideas__list:not(.is-all) .idea:nth-child(n + 5) { display: none; }
  .ideas__more:not([hidden]) { display: block; margin: 0 auto; }
}

/* ---------- maker card ---------- */
.maker {
  display: grid; gap: 18px; padding: 16px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 980px) {
  .maker { grid-template-columns: minmax(0, 1fr) 340px; padding: 20px; }
  .tray { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); }
  .maker__actions { grid-column: 1 / -1; }
}
@media (max-width: 520px) { .maker { padding: 10px; gap: 14px; } }

.maker__top { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; margin-bottom: 12px; }
.maker__title-field { display: grid; gap: 4px; font-weight: 700; flex: 1 1 220px; max-width: 360px; }
.maker__title-field span { font-size: .9rem; color: var(--muted); }
.maker input, .maker textarea, .maker select {
  font: inherit; color: var(--text); background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px;
}
.maker__history { display: flex; gap: 6px; }

.tool {
  font: 700 .95rem/1 var(--body); color: var(--ink); background: var(--card); border: 2px solid var(--ink);
  border-radius: 10px; padding: 9px 12px; cursor: pointer; min-height: 44px;
}
.tool:hover:not(:disabled) { background: var(--accent-tint); }
.tool:disabled { opacity: .4; cursor: default; }
.tool[aria-pressed="true"] { background: var(--ink); color: #fff; }
.tool--danger { color: var(--red); border-color: var(--red); }

/* the strip row: three small panels, the one being edited outlined */
.strip-row { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.strip-row button {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 10px;
  font: 700 .85rem/1 var(--body); color: var(--muted);
}
.strip-row button > svg { display: block; width: 100%; height: auto; border-radius: 8px; outline: 3px solid transparent; outline-offset: 2px; }
.strip-row button[aria-current="true"] > svg { outline-color: var(--accent); }
.strip-row button[aria-current="true"] { color: var(--accent); }
.strip-row span { display: block; margin-top: 6px; }

.stage { position: relative; max-width: 640px; margin: 0 auto; }
.stage__svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage__empty {
  position: absolute; left: 12%; right: 12%; top: 40%; margin: 0; padding: 12px 14px; text-align: center;
  background: var(--caption); border: var(--outline); border-radius: 12px; font-weight: 700; pointer-events: none;
}
.stage__empty[hidden] { display: none; }

[data-id] { cursor: grab; }
.dragging [data-id] { cursor: grabbing; }
.sel-box { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 10 7; pointer-events: none; }
.handle { fill: #fff; stroke: var(--accent); stroke-width: 4; cursor: nwse-resize; }
.handle--tail { fill: var(--accent); stroke: #fff; cursor: move; }
.handle--rot { cursor: grab; }
.handle-hit { fill: transparent; stroke: none; }

/* ---------- selection bar ---------- */
.selbar {
  margin-top: 12px; padding: 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--accent-tint);
  display: grid; gap: 10px;
}
.selbar[hidden] { display: none; }
.selbar__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.selbar__label { font-weight: 800; font-size: .85rem; color: var(--muted); min-width: 3.5em; }
.selbar textarea { width: 100%; min-height: 64px; resize: vertical; text-transform: none; }
.selbar input[type=range] { flex: 1; min-width: 120px; accent-color: var(--accent); min-height: 32px; }
.selbar__hint { margin: 0; font-size: .85rem; color: var(--muted); }
.chip {
  font: 700 .85rem/1 var(--body); color: var(--ink); background: #fff; border: 2px solid var(--ink);
  border-radius: 999px; padding: 8px 12px; cursor: pointer; min-height: 36px; text-transform: capitalize;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- tray ---------- */
.tray { display: flex; flex-direction: column; min-height: 0; border: 2px solid var(--ink); border-radius: 14px; overflow: hidden; background: #fff; }
.tray__tabs { display: flex; gap: 4px; padding: 8px; overflow-x: auto; border-bottom: 2px solid var(--ink); background: var(--bg); flex: none; }
.tray__tabs button {
  font: 700 .9rem/1 var(--body); color: var(--ink); background: none; border: 2px solid transparent; border-radius: 999px;
  padding: 8px 12px; cursor: pointer; white-space: nowrap; min-height: 38px;
}
.tray__tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.tray__grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; padding: 10px;
  overflow-y: auto; max-height: 360px; align-content: start;
}
@media (min-width: 980px) { .tray__grid { max-height: none; flex: 1; } }
.tray__grid--bg { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.add {
  display: grid; justify-items: center; gap: 4px; padding: 6px 4px; background: #fff; border: 2px solid var(--bg);
  border-radius: 12px; cursor: pointer; font: 700 .78rem/1.15 var(--body); color: var(--ink); text-align: center;
}
.add:hover { border-color: var(--ink); background: var(--accent-tint); }
.add svg { width: 64px; height: 64px; }
.add--bg svg { width: 100%; height: auto; aspect-ratio: 600 / 620; border-radius: 6px; border: 2px solid var(--ink); }
.add--word { min-height: 84px; align-content: center; }
.add__word { font: 400 1.35rem/1 var(--comic); letter-spacing: .04em; }
.add[aria-pressed="true"] { border-color: var(--accent); }

.maker__actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.maker__note { margin: 0; color: var(--muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { .ideas__list { scroll-behavior: auto; } }
@media (prefers-reduced-motion: no-preference) {
  .selbar:not([hidden]) { animation: maker-in .22s ease both; }
  .ideas__list.is-all .idea:nth-child(n + 5) { animation: maker-in .3s ease both; }
  .strip-row button > svg { transition: outline-color .2s ease; }
}
@keyframes maker-in { from { opacity: 0; translate: 0 6px; } }

/* ---------- share a finished comic ---------- */
.share-comic { margin-top: 28px; padding: 24px 28px; }
@media (max-width: 520px) { .share-comic { padding: 20px 16px; } }
.share-comic__title { font-size: 1.4rem; margin-bottom: 14px; }
.share-comic__grid { display: grid; gap: 22px; }
@media (min-width: 720px) { .share-comic__grid { grid-template-columns: 1fr 1fr; } }
.share-comic h3 { font-size: 1.1rem; margin-bottom: 6px; }
.share-comic p { margin-bottom: 12px; }
