/* =========================================================
   Mad Libs Generator — tool-specific styles.
   Layered on top of /tools/_shared/tool.css.
   Only widget-body styles unique to this tool live here.
   ========================================================= */

/* Widen the widget card a bit when showing the gallery or
   the revealed story — both benefit from extra horizontal space. */
.widget-card { transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
body[data-screen="gallery"] .widget-card,
body[data-screen="reveal"]  .widget-card { max-width: 760px; }

/* =========================================================
   Gallery — template picker
   ========================================================= */
.ml-gallery-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  text-align: center;
}

.ml-gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
@media (min-width: 640px) {
  .ml-gallery-grid { grid-template-columns: 1fr 1fr; }
}

.ml-template-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: left;
  padding: var(--space-5);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition-colors), transform 0.12s ease,
              box-shadow 0.15s ease;
}
.ml-template-card:hover,
.ml-template-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  outline: none;
}
.ml-template-eyebrow {
  display: inline-flex;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-soft-fg);
  background: var(--accent-soft-bg);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.ml-template-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}
.ml-template-theme {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}
.ml-template-cta {
  margin-top: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Custom template block ---------- */
.ml-custom {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.ml-custom-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-2);
}
.ml-custom-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
  line-height: 1.5;
}
.ml-custom-types {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  line-height: 1.6;
  word-break: break-word;
}
.ml-custom-input {
  width: 100%;
  min-height: 140px;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  resize: vertical;
  transition: var(--transition-colors);
}
.ml-custom-input::placeholder {
  color: var(--text-subtle);
  white-space: pre-line;
}
.ml-custom-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.ml-custom-status {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}
.ml-custom-status.is-error {
  background: var(--danger-soft-bg);
  color: var(--danger-soft-fg);
  border-color: var(--danger);
}
.ml-custom-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

/* =========================================================
   Fill-in screen
   ========================================================= */
.ml-fill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.ml-fill-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
}
.ml-fill-back {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
}
.ml-fill-back:hover { color: var(--accent); }

.ml-mode-toggle {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-inset);
  margin-bottom: var(--space-5);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: center;
}
.ml-mode-toggle legend {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  padding: 0;
  margin-right: var(--space-2);
}
.ml-mode-toggle label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
}
.ml-mode-toggle input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.ml-mode-toggle input[type="radio"]:checked + span { color: var(--text); font-weight: 600; }

/* ---------- One-at-a-time prompt ---------- */
.ml-prompt-one {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  margin-bottom: var(--space-5);
}
.ml-prompt-progress {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin: 0 0 var(--space-3);
}
.ml-prompt-label {
  display: block;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: var(--space-2);
}
@media (min-width: 640px) {
  .ml-prompt-label { font-size: 30px; }
}
.ml-prompt-example {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--space-4);
}
.ml-prompt-input {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 18px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  transition: var(--transition-colors);
}
.ml-prompt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.ml-prompt-input.is-empty {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft-bg);
}
.ml-prompt-progress-bar {
  margin-top: var(--space-4);
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.ml-prompt-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}

/* ---------- All-at-once list ---------- */
.ml-fill-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.ml-fill-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.ml-fill-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (min-width: 640px) {
  .ml-fill-row {
    grid-template-columns: 200px 1fr auto;
    align-items: center;
    gap: var(--space-3);
  }
}
.ml-fill-row-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.ml-fill-row-input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: var(--transition-colors);
}
.ml-fill-row-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.ml-fill-row-input.is-empty {
  border-color: var(--danger);
  background: var(--danger-soft-bg);
}
.ml-fill-row-example {
  font-size: 12px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
}

/* ---------- Fill actions row ---------- */
.ml-fill-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: space-between;
}
.ml-fill-actions .btn { flex: 1; min-width: 140px; }
.ml-fill-actions .btn-block { flex: 1 1 100%; }

/* =========================================================
   Reveal screen
   ========================================================= */
.ml-reveal-header {
  margin-bottom: var(--space-4);
  text-align: center;
}
.ml-reveal-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin: 0 0 var(--space-2);
}
.ml-reveal-header h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
@media (min-width: 640px) {
  .ml-reveal-header h2 { font-size: 32px; }
}

.ml-reveal-body {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  white-space: pre-wrap;
}
@media (min-width: 640px) {
  .ml-reveal-body { font-size: 18px; padding: var(--space-8); }
}

.ml-fill-word {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 2px solid var(--accent-ring);
  padding-bottom: 1px;
}

.ml-reveal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}
@media (min-width: 640px) {
  .ml-reveal-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* =========================================================
   Print — only the finished story shows on paper
   ========================================================= */
@media print {
  /* Hide everything by default. */
  body * { visibility: hidden; }
  /* Show only the reveal screen contents. */
  #ml-reveal,
  #ml-reveal * { visibility: visible; }
  #ml-reveal {
    position: absolute;
    inset: 0;
    padding: 0;
  }
  #ml-reveal .ml-reveal-actions,
  .toast { display: none !important; }
  /* Clean print styling. */
  .ml-reveal-body {
    border: none;
    background: transparent;
    padding: 0;
    color: #000;
    font-size: 15pt;
    line-height: 1.7;
  }
  .ml-fill-word {
    color: #000;
    text-decoration: underline;
    border-bottom: none;
  }
  .ml-reveal-header h2 { color: #000; font-size: 22pt; }
  .ml-reveal-eyebrow { display: none; }
  /* Hide everything outside the widget. */
  .tool-header,
  .attenda-cta,
  .article,
  .tool-footer,
  .skip-link { display: none !important; }
}
