/*
 * Komponenty Ztraceného receptu mistra Cupruma: úvodní obraz, příběh a dekorace (rytiny alchymistických pomůcek).
 * Společné prvky jsou v /core/css/base.css, barvy a písmo v theme.css. Herní obrazovky (diagram, hádanky, tajenka) přibudou.
 */

/* ---------- Úvodní obraz s názvem hry ---------- */

.hero { position: relative; margin: -4px -6px 18px; overflow: hidden; border-radius: 4px; box-shadow: 0 4px 18px rgba(40, 20, 5, 0.35); }
.hero img { width: 100%; height: auto; }
/* Název hry v tmavé horní části obrazu: světlý text se stínem (obraz je tmavý ve všech jazycích). */
.hero-title {
  position: absolute;
  inset: 0 0 auto;
  margin: 0;
  padding: 4% 6% 0;
  text-align: center;
  font-size: clamp(1.25rem, 4.4vw, 2.2rem);
  color: #f6e4bb;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 18px rgba(0, 0, 0, 0.7);
}

/* ---------- Příběh z pergamenu ---------- */

.story { text-align: left; }
.story p { margin: 0.7em 0; }
.margin-note {
  margin: 1em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--highlight);
  background: rgba(154, 84, 24, 0.07);
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 1.08em;
  color: var(--heading);
}

/* ---------- Dekorace: rytiny pomůcek ve volném místě po stranách (jen na širokých obrazovkách) ---------- */
/* Rytiny mají bílé pozadí, multiply je „vpije“ do pergamenu. */

@media (min-width: 1180px) {
  body:not(.admin-body):not(.print-body)::before,
  body:not(.admin-body):not(.print-body)::after {
    content: '';
    position: fixed;
    bottom: calc(var(--footer-h) + 8px);
    z-index: -1;
    width: min(24vw, 300px);
    height: min(34vw, 420px);
    background-repeat: no-repeat;
    background-size: contain;
    mix-blend-mode: multiply;
    opacity: 0.55;
    pointer-events: none;
  }
  body:not(.admin-body):not(.print-body)::before { left: 2vw; background-image: url('/img/deco-alembik.jpg'); background-position: left bottom; }
  body:not(.admin-body):not(.print-body)::after { right: 2vw; background-image: url('/img/deco-vazky.jpg'); background-position: right bottom; }
  /* Laboratoř je široká – rytiny by ležely pod panely. */
  body:has(.lab-screen)::before, body:has(.lab-screen)::after { display: none; }
}

/* ---------- Horní lišta hry ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--edge);
  box-shadow: 0 2px 10px rgba(60, 35, 10, 0.18);
  font-size: 0.95rem;
}
.topbar[hidden] { display: none; }
.topbar .who { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--heading); white-space: nowrap; }
.timer.warn { color: var(--late); }
.timer.over { color: var(--bad); }
.timer.ok { color: var(--ok); }
.letters { display: flex; gap: 4px; }
.letter {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 30px;
  border-radius: 4px;
  background: var(--notice-bg);
  border: 1px solid var(--highlight);
  color: var(--heading);
  font-family: var(--font-heading);
  font-weight: 700;
}
.letter.empty { background: transparent; border-style: dashed; border-color: var(--edge); color: var(--muted); }
.letter.small { width: 22px; height: 24px; font-size: 0.85em; vertical-align: middle; }
@media (max-width: 560px) { .topbar .who { display: none; } .letter { width: 22px; height: 26px; } }

/* ---------- Úvod hry ---------- */

.intro-screen .pane + .pane { margin-top: 18px; }
.how h2 { margin-top: 0; font-family: var(--font-heading); color: var(--heading); }
.how ol { margin: 0; padding-left: 1.3em; }
.how li { margin: 0.35em 0; }
.start-box { text-align: center; }
.who-big { margin-top: 0; font-weight: 600; color: var(--heading); }
.note { margin: 8px 0; }

/* ---------- Laboratoř ---------- */

.lead { max-width: 820px; margin: 0 auto 18px; }
.lab { display: grid; gap: 18px; align-items: start; }
@media (min-width: 900px) { .lab { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.side { display: grid; gap: 18px; }
.lab-screen .notes { margin-top: 18px; }
.lab-screen .word { margin-bottom: 18px; }

/* Schéma: uzly jsou HTML prvky nad SVG se šipkami ve stejných souřadnicích (viewBox 300 × 310). */
.diagram { position: relative; width: 100%; max-width: 520px; margin: 0 auto; aspect-ratio: 300 / 310; }
.diagram svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.arrow path { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; }
.arrow.secret path { stroke: var(--highlight); stroke-dasharray: 6 4; }
.arrow circle { fill: var(--notice-bg); stroke: var(--highlight); stroke-width: 1.2; }
.arrow text { font: 700 10px var(--font-heading); text-anchor: middle; fill: var(--heading); }
.head { fill: var(--accent); }
.head.secret { fill: var(--highlight); }
.arrow.fresh path { stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw 1.2s ease-out forwards; }
.arrow.secret.fresh path { stroke-dasharray: 6 4; stroke-dashoffset: 0; animation: none; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.node {
  position: absolute;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 3px solid var(--edge);
  background: var(--field-bg);
}
.node img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
button.node { cursor: pointer; box-shadow: 0 3px 10px rgba(60, 35, 10, 0.3); transition: transform 0.15s, box-shadow 0.15s; }
button.node:hover { transform: scale(1.05); }
button.node:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.node.selected { border-color: var(--highlight); box-shadow: 0 0 0 4px rgba(154, 84, 24, 0.35), 0 3px 12px rgba(60, 35, 10, 0.35); }
.node.hidden { border: 2.5px dashed var(--edge); background: rgba(255, 250, 240, 0.55); }
.node .q { font: 700 clamp(1.2rem, 4vw, 1.9rem) var(--font-heading); color: var(--muted); }
.node-id {
  position: absolute;
  top: -6%;
  left: -6%;
  display: grid;
  place-items: center;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--heading);
  color: var(--on-highlight);
  font: 700 clamp(0.7rem, 2vw, 0.95rem) var(--font-heading);
}
.node.fresh { animation: reveal 1.4s ease-out; }
@keyframes reveal { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; box-shadow: 0 0 0 10px rgba(154, 84, 24, 0.25); } 100% { transform: scale(1); } }

/* Panel uzlu: volba pokusu a pozorování */
.node-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.node-head img { width: 76px; height: 76px; flex: none; border-radius: 50%; border: 2px solid var(--edge); object-fit: cover; }
.node-head h2 { margin: 0; font-family: var(--font-heading); color: var(--heading); font-size: 1.3rem; }
.node-head p { margin: 2px 0 0; }
.experiment-form fieldset { margin: 12px 0 0; padding: 0; border: 0; }
.experiment-form legend { margin-bottom: 6px; font-weight: 600; color: var(--heading); }
.choice { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0; padding: 8px 12px; border: 1px solid var(--divider); border-radius: 8px; background: var(--field-bg); cursor: pointer; }
.choice:hover { border-color: var(--edge); }
.choice input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--highlight); background: var(--notice-bg); }
.choice.done { cursor: default; color: var(--muted); background: transparent; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 8px; }
.exp-done { padding-left: 1.2em; }
.msg { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.msg.ok { background: rgba(39, 96, 36, 0.1); color: var(--ok); }
.msg.wrong { background: var(--error-bg); color: var(--bad); }
.wait { margin: 10px 0 0; font-weight: 600; color: var(--late); font-variant-numeric: tabular-nums; }
.experiment-form .actions { justify-content: flex-start; }

/* Hádanka */
.riddle h2, .notes h2, .word h2 { margin: 0 0 6px; font-family: var(--font-heading); color: var(--heading); font-size: 1.25rem; }
.poem {
  margin: 12px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--highlight);
  background: rgba(154, 84, 24, 0.06);
  white-space: pre-line;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05em;
  line-height: 1.55;
  max-height: 26em;
  overflow-y: auto;
}
.hints { margin: 8px 0; padding: 8px 12px; border-radius: 8px; background: var(--notice-bg); }
.riddle-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.riddle-form label { display: grid; gap: 4px; font-weight: 600; color: var(--heading); }
.riddle-form input {
  width: 7em;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--edge);
  background: var(--field-bg);
  color: var(--text);
  font: 700 1.2rem var(--font-body);
  text-align: center;
}
.riddle-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.riddle-form input::placeholder { color: var(--placeholder); font-weight: 400; font-size: 1rem; }

/* Zápisník proměn */
.notes-list { margin: 0; padding-left: 1.4em; }
.notes-list li { margin: 10px 0; }
.notes-list li.fresh { animation: note-flash 2.5s ease-out; }
@keyframes note-flash { 0%, 30% { background: var(--flash-bg); } 100% { background: transparent; } }
.note-head { margin: 0; }
/* Rovnice: nad šipkou je podmínka (Δ, H₂O) vysázená menším písmem; místo nad řádkem drží padding. */
.equation { margin: 2px 0; padding: 0.75em 0 0.15em; overflow-x: auto; overflow-y: hidden; font-size: 1.08em; line-height: 1.4; white-space: nowrap; }
.equation .arrow { position: relative; display: inline-block; margin: 0 0.3em; padding: 0 0.15em; font-size: 1.15em; line-height: 1; }
.equation .arrow .over { position: absolute; left: 50%; bottom: 82%; transform: translateX(-50%); font-size: 0.62em; white-space: nowrap; }

/* Tajenka */
.word { text-align: center; }
.pool, .slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0; }
.pool { min-height: 66px; padding: 6px; border-radius: 8px; border: 1px dashed var(--divider); }
.slot { display: grid; place-items: center; width: 52px; height: 58px; border-radius: 6px; border: 2px dashed var(--edge); background: rgba(255, 250, 240, 0.6); }
.slot.filled { border-style: solid; }
.tile {
  display: grid;
  place-items: center;
  width: 48px;
  height: 54px;
  padding: 0;
  border-radius: 5px;
  border: 1.5px solid var(--highlight);
  background: linear-gradient(180deg, #fff6e2, #efd9ab);
  color: var(--heading);
  font: 700 1.6rem var(--font-heading);
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: 0 2px 4px rgba(60, 35, 10, 0.25);
}
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile.dragging { opacity: 0.35; }
.tile.ghost { position: fixed; z-index: 70; pointer-events: none; cursor: grabbing; box-shadow: 0 8px 18px rgba(60, 35, 10, 0.4); }
.word.solved .slot { border-color: var(--highlight); }
.slots.glow .tile { animation: glow 2.4s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 0 4px rgba(255, 190, 90, 0.6); } to { box-shadow: 0 0 22px 6px rgba(255, 180, 60, 0.85); } }
/* Na telefonu se sedm okének musí vejít do jednoho řádku. */
@media (max-width: 460px) {
  .pool, .slots { gap: 4px; }
  .word.pane { padding-left: 12px; padding-right: 12px; }
  .slot { width: 38px; height: 46px; }
  .tile { width: 34px; height: 42px; font-size: 1.25rem; }
}

/* Písmeno po vyřešení hádanky */
.letter-modal .big-letter { display: inline-grid; place-items: center; width: 76px; height: 84px; border-radius: 8px; border: 2px solid var(--highlight); background: var(--notice-bg); font-size: 2.6rem; }

/* ---------- Závěr ---------- */

.ending .vitriol { text-align: center; font-size: clamp(2.2rem, 8vw, 3.6rem); letter-spacing: 0.12em; color: var(--highlight); text-shadow: 0 0 18px rgba(255, 180, 60, 0.55), 0 1px 0 #fff3d6; }
.ending .result { font-weight: 600; }
.ending .result.ok { color: var(--ok); }
.ending .result.late { color: var(--late); }
.reactions { padding-left: 1.2em; }
.reactions .equation { padding: 6px 10px; border-radius: 6px; background: rgba(154, 84, 24, 0.07); }
.warning { padding: 10px 14px; border-left: 3px solid var(--bad); background: var(--error-bg); font-size: 0.95em; }

@media (prefers-reduced-motion: reduce) {
  .arrow.fresh path, .node.fresh, .notes-list li.fresh, .slots.glow .tile { animation: none; }
}
