/* ============================================================
   QUEST GENERATOR — STYLESHEET
   Load order:  impheim.css  →  tool-page.css  →  this file
   ============================================================ */

:root {
  --q-hook:        #4a8fc2;
  --q-complication:#c8903a;
  --q-consequence: #c85c3a;
  --q-climax:      #9060e8;
  --q-good:        #3a9a5c;
  --q-mixed:       #b0922a;
  --q-bad:         #b84040;
  --q-twist:       #c0a030;
  --q-clue-phys:   #6a9ec0;
  --q-clue-soc:    #9a7cc8;
  --q-clue-doc:    #c8a840;
  --q-clue-env:    #5a9a6a;
  --q-border:      rgba(255,255,255,0.07);
  --q-surface:     rgba(255,255,255,0.04);
}

/* ---- QUEST OUTPUT WRAPPER ---- */
#questOutput {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 10px 60px;
}
#questOutput.hidden { display: none; }

/* ---- QUEST HEADER ---- */
.quest-header {
  text-align: center;
  padding: 32px 20px 24px;
  border-bottom: 1px solid var(--q-border);
  margin-bottom: 8px;
}
.quest-title {
  font-family: var(--font-d);
  font-size: clamp(1.5em, 3vw, 2.2em);
  font-weight: 700;
  letter-spacing: 1px;
  color: #f0e8c8;
  margin-bottom: 12px;
  line-height: 1.2;
}
.quest-tier-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.quest-tier-badge {
  display: inline-block;
  font-family: var(--font-d);
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 0.3em 1em;
  border-radius: 20px;
  border: 1.5px solid;
  color: var(--tier-color);
  border-color: var(--tier-color);
  background: color-mix(in srgb, var(--tier-color) 12%, transparent);
}
.quest-tagline {
  font-size: 0.88em;
  color: rgba(255,255,255,0.38);
  font-style: italic;
  letter-spacing: 0.5px;
}
.quest-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quest-tag {
  font-size: 0.75em;
  padding: 0.2em 0.7em;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
}

/* ---- SECTION HEADERS ---- */
.section-heading {
  font-family: var(--font-d);
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  text-align: center;
  padding: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.section-heading::before,
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

/* ---- FLOW NODES ---- */
.quest-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
}

.flow-node {
  width: 100%;
  max-width: 700px;
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-left: 3px solid var(--node-color, rgba(255,255,255,0.2));
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4),
              inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative;
}
.flow-node::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--node-color, white) 60%, transparent),
    transparent 80%);
}

.node-label {
  font-family: var(--font-d);
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--node-color, rgba(255,255,255,0.4));
  margin-bottom: 10px;
}
.node-body {
  font-size: 0.95em;
  line-height: 1.7;
  color: rgba(220,210,240,0.88);
  font-family: 'Palatino Linotype', Georgia, serif;
}

.flow-node.hook         { --node-color: var(--q-hook); }
.flow-node.complication { --node-color: var(--q-complication); }
.flow-node.consequence  { --node-color: var(--q-consequence); }
.flow-node.climax       { --node-color: var(--q-climax); }

/* ---- FLOW CONNECTORS ---- */
.flow-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: rgba(255,255,255,0.25);
}
.connector-line {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.12);
}
.connector-text {
  font-size: 0.78em;
  font-style: italic;
  letter-spacing: 0.5px;
}
.connector-arrow {
  font-size: 0.65em;
  line-height: 1;
  margin-top: -2px;
}

/* ---- RESOLUTIONS ---- */
.quest-resolutions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  max-width: 700px;
  margin: 0 auto;
}
@media (max-width: 680px) {
  .quest-resolutions { grid-template-columns: 1fr; }
}
.resolution {
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 3px 14px rgba(0,0,0,0.35);
}
.resolution-label {
  font-family: var(--font-d);
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.resolution-label .res-icon { font-size: 1.1em; }
.resolution.good  .resolution-label { color: var(--q-good); }
.resolution.mixed .resolution-label { color: var(--q-mixed); }
.resolution.bad   .resolution-label { color: var(--q-bad); }
.resolution.good  { border-left: 2px solid var(--q-good); }
.resolution.mixed { border-left: 2px solid var(--q-mixed); }
.resolution.bad   { border-left: 2px solid var(--q-bad); }
.resolution-body {
  font-size: 0.84em;
  line-height: 1.6;
  color: rgba(220,210,240,0.75);
  font-family: 'Palatino Linotype', Georgia, serif;
}

/* ---- NPC CARDS ---- */
.npc-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.npc-card {
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  transition: box-shadow 0.2s ease;
}
.npc-card:hover {
  box-shadow: 0 6px 28px rgba(0,0,0,0.55),
              0 0 0 1px rgba(255,255,255,0.06);
}
.npc-card-main {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  cursor: default;
}
.npc-name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.npc-name {
  font-family: var(--font-d);
  font-size: 1em;
  font-weight: 700;
  color: #e8d8a8;
  letter-spacing: 0.3px;
}
.npc-race-role {
  font-size: 0.8em;
  color: rgba(255,255,255,0.42);
  font-family: 'Palatino Linotype', Georgia, serif;
}
.npc-appearance {
  font-size: 0.84em;
  color: rgba(220,210,240,0.72);
  font-family: 'Palatino Linotype', Georgia, serif;
  line-height: 1.5;
  margin-bottom: 5px;
  font-style: italic;
}
.npc-voice {
  font-size: 0.82em;
  color: rgba(220,210,240,0.62);
  font-family: 'Palatino Linotype', Georgia, serif;
  line-height: 1.5;
}
.npc-voice b {
  font-family: var(--font-d);
  font-size: 0.75em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-right: 4px;
  font-style: normal;
}

/* Secret */
.npc-secret-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.secret-label {
  font-family: var(--font-d);
  font-size: 0.68em;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.secret-label.mundane  { color: rgba(180,180,180,0.6); }
.secret-label.personal { color: #8ab0cc; }
.secret-label.criminal { color: #cc9840; }
.secret-label.horrific { color: #cc4848; }
.secret-text {
  font-size: 0.85em;
  line-height: 1.6;
  color: rgba(220,210,240,0.8);
  font-family: 'Palatino Linotype', Georgia, serif;
  font-style: italic;
}

/* Expand button */
.npc-expand-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.45);
  font-family: var(--font-d);
  font-size: 0.68em;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.4em 0.9em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  align-self: start;
  margin-top: 2px;
}
.npc-expand-btn:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}
.npc-expand-btn.open {
  color: #c0a030;
  border-color: rgba(192,160,48,0.35);
  background: rgba(192,160,48,0.08);
}

/* Expanded NPC details */
.npc-details {
  padding: 0 20px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.15);
  display: none;
}
.npc-details.open { display: block; }
.npc-trait-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
}
.npc-trait {
  font-size: 0.84em;
  line-height: 1.55;
  color: rgba(220,210,240,0.82);
  font-family: 'Palatino Linotype', Georgia, serif;
}
.npc-trait b {
  font-family: var(--font-d);
  font-size: 0.72em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-right: 4px;
}

/* ---- CLUES ---- */
.clue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.clue-item {
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: 10px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}
.clue-type-badge {
  font-family: var(--font-d);
  font-size: 0.65em;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 0.25em 0.65em;
  border-radius: 8px;
  border: 1px solid;
  white-space: nowrap;
  margin-top: 1px;
}
.clue-type-badge.physical      { color: var(--q-clue-phys); border-color: color-mix(in srgb, var(--q-clue-phys) 40%, transparent); background: color-mix(in srgb, var(--q-clue-phys) 10%, transparent); }
.clue-type-badge.social        { color: var(--q-clue-soc);  border-color: color-mix(in srgb, var(--q-clue-soc)  40%, transparent); background: color-mix(in srgb, var(--q-clue-soc)  10%, transparent); }
.clue-type-badge.documentary   { color: var(--q-clue-doc);  border-color: color-mix(in srgb, var(--q-clue-doc)  40%, transparent); background: color-mix(in srgb, var(--q-clue-doc)  10%, transparent); }
.clue-type-badge.environmental { color: var(--q-clue-env);  border-color: color-mix(in srgb, var(--q-clue-env)  40%, transparent); background: color-mix(in srgb, var(--q-clue-env)  10%, transparent); }

.clue-content { min-width: 0; }
.clue-text {
  font-size: 0.88em;
  line-height: 1.6;
  color: rgba(220,210,240,0.85);
  font-family: 'Palatino Linotype', Georgia, serif;
  margin-bottom: 5px;
}
.clue-npc-link {
  font-size: 0.75em;
  color: rgba(255,255,255,0.35);
  font-family: var(--font-d);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.clue-npc-link::before {
  content: '→';
  opacity: 0.6;
}

/* ---- TWIST ---- */
.quest-twist-block {
  max-width: 700px;
  margin: 0 auto;
  background: color-mix(in srgb, var(--q-twist) 6%, var(--q-surface));
  border: 1px solid color-mix(in srgb, var(--q-twist) 25%, transparent);
  border-radius: 14px;
  padding: 22px 26px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.45),
              0 0 0 1px rgba(192,160,48,0.06),
              inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative;
}
.twist-label {
  font-family: var(--font-d);
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--q-twist);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.twist-label::before { content: '★'; font-size: 0.9em; }
.twist-body {
  font-size: 0.95em;
  line-height: 1.75;
  color: rgba(240,228,188,0.9);
  font-family: 'Palatino Linotype', Georgia, serif;
}

/* ---- REWARD ---- */
.quest-reward-block {
  max-width: 700px;
  margin: 0 auto;
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}
.reward-main {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.reward-label {
  font-family: var(--font-d);
  font-size: 0.68em;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  margin-bottom: 6px;
}
.reward-text {
  font-size: 0.93em;
  line-height: 1.6;
  color: rgba(220,210,240,0.85);
  font-family: 'Palatino Linotype', Georgia, serif;
}
.reward-expand-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.45);
  font-family: var(--font-d);
  font-size: 0.68em;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0.45em 1em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.reward-expand-btn:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}
.reward-loot {
  display: none;
  padding: 0 22px 18px;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.15);
}
.reward-loot.open { display: block; }
.reward-loot-inner {
  padding-top: 14px;
  font-size: 0.85em;
  line-height: 1.7;
  color: rgba(220,210,240,0.75);
  font-family: 'Palatino Linotype', Georgia, serif;
}
.reward-loot-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  display: flex;
  gap: 10px;
}
.reward-loot-item:last-child { border-bottom: none; }
.reward-loot-price {
  color: #c0a030;
  white-space: nowrap;
  font-family: var(--font-d);
  font-size: 0.9em;
}

/* ---- QUEST BANNER (canvas header) ---- */
.quest-banner {
  display: block;
  width: 100%;
  height: 160px;
  border-radius: 14px 14px 0 0;
  flex-shrink: 0;
}

/* ---- NPC PORTRAIT ---- */
.npc-portrait-slot {
  /* Empty state: no space taken */
}
.npc-portrait-slot:empty { display: none; }
.npc-portrait-wrap {
  width: 205px;
  aspect-ratio: 205 / 230;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}
.npc-portrait-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}
/* On wider screens, float portrait right within expanded NPC details */
@media (min-width: 520px) {
  .npc-portrait-wrap {
    float: right;
    margin: 0 0 12px 18px;
  }
}

/* ---- EMPTY STATE ---- */
.quest-empty {
  text-align: center;
  padding: 80px 20px;
  color: rgba(255,255,255,0.2);
}
.quest-empty-icon {
  font-size: 3em;
  margin-bottom: 16px;
  display: block;
  opacity: 0.4;
}
.quest-empty-text {
  font-family: var(--font-d);
  font-size: 0.9em;
  letter-spacing: 1px;
}

/* ---- ENTER ANIMATION ---- */
@keyframes questFadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.quest-animate {
  animation: questFadeIn 0.5s cubic-bezier(.34,1.2,.64,1) both;
}

/* ---- PRINT ---- */
@media print {
  .controls-bar, .site-nav, #site-nav, #site-footer { display: none !important; }
  #questOutput { max-width: 100%; padding: 0; }

  /* Reset dark-theme surfaces to light */
  body { background: #fff !important; }
  .flow-node, .resolution, .npc-card, .clue-item,
  .quest-twist-block, .quest-reward-block {
    box-shadow: none !important;
    background: #f8f7f4 !important;
    border-color: rgba(0,0,0,0.18) !important;
  }

  /* Main prose text */
  .node-body, .resolution-body, .twist-body,
  .npc-appearance, .npc-voice, .secret-text,
  .npc-trait, .clue-text, .reward-text,
  .reward-loot-inner { color: #1a1612 !important; }

  /* Labels and secondary text */
  .node-label, .resolution-label, .twist-label,
  .npc-name, .npc-race-role, .npc-voice b, .npc-trait b,
  .secret-label, .clue-type-badge, .clue-npc-link,
  .reward-label, .reward-loot-price,
  .section-heading { color: #3a2e1a !important; }

  /* Quest header */
  .quest-title { color: #1a1612 !important; -webkit-text-fill-color: #1a1612 !important; }
  .quest-tagline { color: #5a4e3a !important; }
  .quest-tag { color: #5a4e3a !important; background: rgba(0,0,0,0.05) !important; }
  .quest-tier-badge { color: #3a2e1a !important; }

  /* Expand states */
  .npc-details { display: block !important; background: #f2f0ec !important; }
  .reward-loot { display: block !important; background: #f2f0ec !important; }

  /* Images */
  .quest-banner { border-radius: 0; }
  .npc-portrait-wrap { float: right; margin: 0 0 8px 14px; }
}
