/* The Azo world shell. Logical properties only: the page may be rendered right to left. */
#hero[hidden],
#world[hidden] { display: none; }

#world {
  position: relative;
  inline-size: 100%;
  block-size: calc(100svh - 64px);
  min-block-size: 420px;
  background: #06090e;
  overflow: hidden;
  color: #e7eef5;
}
/* The world fills the screen under the header: 64 px tall on wide screens, 56 px on phones. */
@media (max-width: 860px) {
  #world { block-size: calc(100svh - 56px); }
}

/* Finish: a vignette and a whisper of film grain over the canvas, under the HUD. */
#world::before,
#world::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#world::after { background: radial-gradient(125% 95% at 50% 46%, transparent 56%, rgba(2, 5, 9, 0.62) 100%); }
#world::before {
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

#world-canvas {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  touch-action: pan-y;
}

#world-caption,
#world-actions {
  position: absolute;
  inset-inline: 16px;
  z-index: 2;
}

#world-caption { inset-block-end: 76px; text-align: center; font-size: 1.05rem; }
#world-actions { inset-block-end: 16px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

#world-classic {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  z-index: 3;
  padding: 8px 12px;
  border: 1px solid #0fb4a8;
  border-radius: 999px;
  background: rgba(6, 9, 14, 0.7);
  color: #34e0cf;
  font-size: 0.9rem;
  text-decoration: none;
}
#world-classic:focus-visible { background: #0fb4a8; color: #06090e; outline: 2px solid #e7eef5; outline-offset: 2px; }

html[data-world="pending"] #hero { display: none; }
html[data-world="pending"] #world { display: block; }

/* ---- HUD (Task 2) ------------------------------------------------------------------------- */
#world-caption { inset-block-end: 84px; pointer-events: none; }
#world-caption-text {
  display: inline-block;
  max-inline-size: min(640px, 100%);
  padding: 12px 20px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02)), rgba(8, 14, 22, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 50px -22px #000, inset 0 1px 0 rgba(255, 255, 255, 0.08);
  line-height: 1.4;
}
#world-actions button,
#world-actions a {
  min-block-size: 44px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(8, 14, 22, 0.78);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px -16px #000, inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #e7eef5;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s; /* not background or colour: hover flips both at once, so text is never dark on dark */
}
@media (hover: hover) {
  #world-actions button:hover { background: #0fb4a8; color: #06090e; border-color: #34e0cf; box-shadow: 0 0 24px -4px rgba(52, 224, 207, 0.65); }
}
#world-actions button:focus-visible, #world-actions a:focus-visible { outline: 2px solid #34e0cf; outline-offset: 3px; }
#world-actions a { display: inline-flex; align-items: center; box-sizing: border-box; background: #0fb4a8; color: #06090e; font-weight: 700; text-decoration: none; }
#world-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

#world-overlay {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-inline-size: calc(100% - 200px);
}
#world-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #ef9f27;
  color: #ef9f27;
  background: rgba(6, 9, 14, 0.7);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase; /* the copy stays sentence case for screen readers */
}
#world-chip[hidden] { display: none; }
/* A backing of its own: a star or a glow can sit right behind it, and the text keeps 4.5:1 over it. */
#world-progress { padding: 4px 10px; border-radius: 999px; background: rgba(6, 9, 14, 0.7); font-size: 0.85rem; color: #d9e1e8; }

#world-debrief, #world-handoff {
  position: absolute;
  z-index: 2;
  inset-block: 56px 150px;
  inset-inline: 16px;
  max-inline-size: 560px;
  margin-inline: auto;
  overflow-y: auto;
  padding: 16px 20px;
  border-radius: 16px;
  background: rgba(6, 9, 14, 0.88);
  border: 1px solid rgba(15, 180, 168, 0.45);
  font-size: 0.95rem;
}
#world-debrief[hidden], #world-handoff[hidden] { display: none; }
#world-handoff h2, #world-debrief h2 { margin: 0 0 8px; font-size: 1.15rem; color: #34e0cf; }
#world-handoff h3, #world-debrief h3 { margin: 12px 0 4px; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
#world-handoff dl, #world-debrief dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; }
#world-handoff dt, #world-debrief dt { opacity: 0.75; }
#world-handoff dd, #world-debrief dd { margin: 0; }
#world-debrief table { inline-size: 100%; border-collapse: collapse; }
#world-debrief th, #world-debrief td { text-align: start; padding: 3px 6px; border-block-end: 1px solid rgba(231, 238, 245, 0.12); }
#world-debrief td.num { font-variant-numeric: tabular-nums; text-align: end; }
#world-handoff ul, #world-debrief ul { margin: 0; padding-inline-start: 1.1em; }
.debrief-honest { margin: 12px 0 0; padding: 8px 10px; border-inline-start: 3px solid #ef9f27; background: rgba(239, 159, 39, 0.08); }
.debrief-note { margin: 10px 0 0; opacity: 0.85; }


@media (max-width: 600px) {
  /* Smaller chips and a tighter caption on a phone: more of the scene, and the long captions take fewer lines. */
  #world-overlay { max-inline-size: calc(100% - 24px); inset-block-start: 52px; gap: 6px; }
  #world-chip { font-size: 0.68rem; letter-spacing: 0.08em; padding: 3px 9px; }
  #world-progress { font-size: 0.78rem; padding: 3px 9px; }
  #world-status { font-size: 0.72rem; padding: 2px 9px; }
  #world-classic { font-size: 0.82rem; padding: 6px 12px; inset-block-start: 10px; }
  #world-caption-text { padding: 9px 14px; border-radius: 14px; font-size: 0.88rem; line-height: 1.35; }
  #world-debrief, #world-handoff { inset-block: 90px 215px; padding: 12px 14px; font-size: 0.85rem; }
  #world-handoff h3, #world-debrief h3 { margin-block-start: 8px; }
  #world-caption { inset-block-end: 146px; font-size: 0.95rem; }
  #world-actions button, #world-actions a { flex: 1 1 40%; justify-content: center; }
}

/* ---- Azo + core (Task 3) ------------------------------------------------------------------- */
/* A click on the scene skips the wake-up, so say so with the cursor. */
#world[data-act="wake"] #world-canvas { cursor: pointer; }

/* ---- printing world (Task 4) -------------------------------------------------------------- */
/* Dragging the PO and the challan needs the touch to stay on the canvas instead of scrolling. */
#world[data-act="printing"] #world-canvas { touch-action: none; }
#world-actions button[data-action="complete"] { border-color: #34e0cf; }
@media (max-width: 600px) {
  /* Five printing (or rental) buttons wrap to three rows: lift the caption clear of them. */
  #world[data-act="printing"] #world-caption { inset-block-end: 184px; }
  /* rental's longer labels make its bar a few pixels taller than printing's */
  #world[data-act="rental"] #world-caption { inset-block-end: 192px; }
  #world[data-act="printing"] #world-actions button, #world[data-act="rental"] #world-actions button { min-block-size: 44px; padding: 8px 10px; font-size: 0.92rem; }
}
/* A spent (disabled) step must not light up under the pointer. */
@media (hover: hover) {
  #world-actions button:disabled:hover { background: rgba(6, 9, 14, 0.85); color: #e7eef5; }
}
/* Engines read as one line of tags, so the debrief fits without scrolling on a laptop. */
#world-debrief .debrief-block ul { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-inline-start: 0; list-style: none; }
#world-debrief .debrief-block li::before { content: "\2022"; margin-inline-end: 6px; color: #34e0cf; }
#world-debrief .debrief-honest { margin-block: 4px 6px; }
@media (max-width: 600px) and (max-height: 700px) {
  #world[data-act="printing"] #world-actions, #world[data-act="rental"] #world-actions { gap: 6px; inset-block-end: 10px; }
  #world[data-act="printing"] #world-actions button, #world[data-act="rental"] #world-actions button { min-block-size: 40px; padding: 6px 10px; font-size: 0.88rem; }
  #world[data-act="printing"] #world-caption, #world[data-act="rental"] #world-caption { inset-block-end: 160px; font-size: 0.88rem; }
  #world[data-act="rental"] #world-caption { inset-block-end: 168px; }
  #world[data-act="printing"] #world-caption-text, #world[data-act="rental"] #world-caption-text { padding: 8px 12px; }
}
/* ---- Pharmacy (Task 5) ---------------------------------------------------------------------- */
#world-status { padding: 3px 10px; border-radius: 999px; border: 1px solid #e24b4a; color: #e7eef5; background: rgba(6, 9, 14, 0.7); font-size: 0.8rem; }
/* Empty, the live region stays rendered (so announcements are reliable) but takes no room. */
#world-status:empty { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); padding: 0; border: 0; white-space: nowrap; }
/* A pick button carries lot, strips left and expiry on two lines. */
#world-actions button[data-action^="pick-"] { white-space: pre-line; line-height: 1.25; padding-block: 6px; }
@media (max-width: 600px) {
  #world[data-act="pharmacy"] #world-caption { inset-block-end: 150px; }
  #world[data-act="pharmacy"] #world-actions { gap: 6px; }
  #world[data-act="pharmacy"] #world-actions button { flex: 1 1 28%; min-block-size: 44px; padding: 6px 4px; font-size: 0.85rem; }
  #world[data-act="pharmacy"] #world-actions button[data-action^="pick-"] { font-size: 0.78rem; }
}
/* ---- School and finale (Task 6) ---------------------------------------------------------- */
/* The honest label rides in the status pill: amber, not the pharmacy's mistake red. */
#world[data-act="school"] #world-status { border-color: #ef9f27; color: #ef9f27; }
/* Rental is built and shown on a demo company: its honest label is amber too. */
#world[data-act="rental"] #world-status { border-color: #ef9f27; color: #ef9f27; }
#world[data-act="school"] #world-canvas { touch-action: none; }
#world-handoff li { margin-block: 2px; }
/* The finale recap is as tall as its text, never stretched over an empty panel. */
#world-handoff { inset-block-end: auto; max-block-size: calc(100% - 206px); }
@media (max-width: 600px) {
  #world-handoff { max-block-size: calc(100% - 360px); }
  #world-handoff { font-size: 0.8rem; line-height: 1.35; }
  #world-handoff dl { gap: 1px 10px; }
  #world[data-act="finale"] #world-caption { inset-block-end: 140px; }
}
/* ---- Task 7 fixes --------------------------------------------------------------------------- */
/* The caption text takes a touch itself, so a swipe that starts on it scrolls the page even where the
   canvas below takes drags; taps on the caption area otherwise still fall through to the scene. */
#world-caption-text { pointer-events: auto; touch-action: pan-y; }
@media (max-width: 600px) {
  /* A finale with only two actions (all four played) fits on one row: the caption sits lower and
     the recap gets the room, so its last line is never under the caption. */
  #world[data-act="finale"]:has(#world-actions > :nth-child(2):last-child) #world-caption { inset-block-end: 84px; }
  #world[data-act="finale"]:has(#world-actions > :nth-child(2):last-child) #world-handoff { max-block-size: calc(100% - 276px); }
}
/* The amber chip and the status pill sit on an opaque ink backing: their text keeps 4.5:1 whatever the
   scene puts behind them, a white glow included. */
#world-chip, #world-status { background: #06090e; }
/* Shown from the moment the section is visible until the first frame is drawn. */
#world-loading { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; color: #d9e1e8; font-size: 1rem; }
#world[data-frames] #world-loading, #world-loading[hidden] { display: none; }
@media (hover: hover) {
  #world-classic:hover { background: #0fb4a8; color: #06090e; outline: 2px solid #e7eef5; outline-offset: 2px; }
}

/* the shared-platform panel */
#world-platform { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
#world-platform-btn {
  position: absolute; left: var(--core-x, 50%); top: var(--core-y, 40%); transform: translate(-50%, -50%);
  pointer-events: auto; min-block-size: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(160, 238, 232, 0.55); background: rgba(7, 13, 19, 0.55); color: #eaf7f6; font: 600 13px Inter, system-ui, sans-serif;
}
#world-platform-btn[hidden] { display: none; }
#world-platform-btn:focus-visible { outline: 2px solid #34e0cf; outline-offset: 3px; }
/* readable by assistive tech everywhere, visible only when opened on a phone */
#world-platform-panel {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
/* opened: the pill and the card stack above the caption bar, so the pill stays clickable to close it */
#world-platform[data-compact="1"][data-open="1"] {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 8px;
  padding: 0 16px 232px; box-sizing: border-box;
}
#world-platform[data-compact="1"][data-open="1"] #world-platform-btn { position: static; transform: none; align-self: center; }
#world-platform[data-compact="1"][data-open="1"] #world-platform-panel {
  position: static; width: auto; height: auto; clip-path: none; white-space: normal; overflow: visible; pointer-events: auto;
  padding: 12px 14px; border-radius: 14px; box-sizing: border-box;
  background: rgba(7, 13, 19, 0.92); border: 1px solid rgba(160, 238, 232, 0.45); color: #eaf7f6; font-size: 13px;
}
#world-platform-panel h3 { margin: 0 0 6px; font-size: 13px; }
#world-platform-panel p { margin: 0 0 6px; }
#world-platform-panel ul { margin: 0; padding-left: 18px; }
#world-platform-panel p.addon { margin: 8px 0 0; color: #ffd9a0; }
