/* ==========================================================================
   ASHTAR KATKOOT — ADVENTURE COMPLETION CARD
   --------------------------------------------------------------------------
   A celebratory reward screen shown over the dimmed game scene.

   NOTHING HERE DECIDES ANYTHING. Every piece of state - the words, the stars,
   the percentage, the animals, and which buttons exist - arrives from
   ashtar-complete-card.js. This file only draws it.

   The scene behind is not an image: the panel is built from layered wooden
   borders, parchment gradients and CSS-drawn foliage, so the card stays a
   few kilobytes and the game's own artwork is never covered by a screenshot.
   ========================================================================== */

/* ---------------------------------------------------------------- *
   THE DIMMED SCENE BEHIND
   ---------------------------------------------------------------- */
.ashtar-done {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* The top inset clears the notch. The bottom inset now lives on the action
     footer, so it is not counted twice. */
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* A warm vignette rather than flat black: the jungle is still there. */
  background:
    radial-gradient(120% 80% at 50% 30%, rgba(20, 40, 18, 0.30) 0%, rgba(10, 22, 10, 0.72) 70%, rgba(6, 14, 6, 0.88) 100%);
  -webkit-backdrop-filter: blur(3px) saturate(0.85);
  backdrop-filter: blur(3px) saturate(0.85);
}

/* ---------------------------------------------------------------- *
   THE PANEL — wooden frame with a parchment face
   ---------------------------------------------------------------- */
.ashtar-done-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow: hidden;
  border-radius: 26px;
  padding: 16px 14px 12px;
  text-align: center;
  /* Three layers: the raised wooden rim, the dark seam under it, and the
     deep drop that lifts the whole panel off the scene. */
  border: 6px solid #7a4a1e;
  background:
    /* the parchment face */
    linear-gradient(180deg, #fdf0d2 0%, #f6e0b2 45%, #efd3a0 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.85),
    inset 0 -4px 0 rgba(150, 100, 40, 0.35),
    inset 0 0 0 3px rgba(255, 236, 190, 0.55),
    0 0 0 3px #a9713a,
    0 0 0 7px #5e3614,
    0 16px 34px rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

/* Foliage tucked into the four corners of the frame. Drawn, not pictured, so
   it costs nothing and never looks like a pasted photograph. */
.ashtar-done-panel::before,
.ashtar-done-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 74px;
  pointer-events: none;
  z-index: 0;
}

.ashtar-done-panel::before {
  top: 0;
  border-radius: 20px 20px 0 0;
  background:
    radial-gradient(16px 10px at 6% 22px, #4fae4f 60%, transparent 62%),
    radial-gradient(14px 9px at 20% 12px, #63c25c 60%, transparent 62%),
    radial-gradient(18px 11px at 82% 14px, #4fae4f 60%, transparent 62%),
    radial-gradient(13px 9px at 95% 24px, #63c25c 60%, transparent 62%),
    linear-gradient(180deg, rgba(64, 160, 64, 0.85), rgba(64, 160, 64, 0));
}

.ashtar-done-panel::after {
  bottom: 0;
  border-radius: 0 0 20px 20px;
  background:
    radial-gradient(20px 12px at 4% 16px, #3f9440 60%, transparent 62%),
    radial-gradient(15px 10px at 24% 8px, #57b04f 60%, transparent 62%),
    radial-gradient(20px 12px at 80% 10px, #3f9440 60%, transparent 62%),
    radial-gradient(14px 9px at 97% 18px, #57b04f 60%, transparent 62%),
    linear-gradient(0deg, rgba(52, 130, 52, 0.8), rgba(52, 130, 52, 0));
}

/* Everything real sits above the decoration. */
.ashtar-done-panel > * { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- *
   THE HEAD — wooden plaque with the celebration, then the adventure
   ---------------------------------------------------------------- */
/* ALWAYS VISIBLE: the kicker and the adventure's name. A flex child of the
   panel, so it can never be scrolled out of reach. */
.ashtar-done-head { flex: 0 0 auto; margin-bottom: 8px; }

/* The celebration, the stars, the percentage and its bar, the tone lines and
   the rewards. `flex: 0 1 auto` with `min-height: 0` keeps its natural height
   when there is room - so the score and the stars are visible without any
   scrolling - and becomes a scrolling region only when the screen is genuinely
   too short to show it all. */
.ashtar-done-body {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.ashtar-done-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #8a6236;
  opacity: 0.9;
  margin-bottom: 6px;
}

/* The adventure's own name, on a glossy green plaque. */
.ashtar-done-title {
  display: inline-block;
  margin: 0 0 8px;
  padding: 6px 20px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.25;
  color: #ffffff;
  background: linear-gradient(180deg, #7ede6e 0%, #3fae49 55%, #2a8a37 100%);
  border: 3px solid #1f6b2b;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 4px 10px rgba(0, 0, 0, 0.30);
  text-shadow: 0 2px 0 rgba(20, 70, 25, 0.55);
}

/* ---------------------------------------------------------------- *
   THE CELEBRATION — the big line, on carved wood
   ---------------------------------------------------------------- */
.ashtar-done-praise {
  margin: 0 auto 6px;
  padding: 8px 14px;
  max-width: 320px;
  border-radius: 16px;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.3;
  color: #ffe08a;
  background: linear-gradient(180deg, #c07d3f 0%, #9c5f2c 55%, #7d4520 100%);
  border: 3px solid #6b3a17;
  box-shadow:
    inset 0 2px 0 rgba(255, 226, 176, 0.45),
    inset 0 -3px 0 rgba(0, 0, 0, 0.30),
    0 5px 12px rgba(0, 0, 0, 0.35);
  text-shadow: 0 2px 0 #6b3a17, 0 0 14px rgba(255, 200, 80, 0.35);
}

.ashtar-done-sub {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
  color: #7a4f22;
}

/* ---------------------------------------------------------------- *
   THE STARS — large, dimensional, and honest
   ---------------------------------------------------------------- */
.ashtar-done-stars {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 6px 0 8px;
}

.ashtar-done-star {
  font-size: 40px;
  line-height: 1;
  color: #cfc4b4;
  text-shadow: 0 2px 0 rgba(120, 95, 55, 0.35);
}

.ashtar-done-star.is-on {
  color: #ffc93c;
  /* The bevel: a light top edge over a dark bottom one. */
  text-shadow:
    0 3px 0 #e08a00,
    0 6px 0 #a86200,
    0 9px 14px rgba(255, 170, 30, 0.55),
    0 0 18px rgba(255, 200, 60, 0.65);
}

/* A story-only adventure has no score, so it shows no stars at all rather
   than three empty ones that would read as a loss. */
.ashtar-done-stars.is-story { display: none; }

/* ---------------------------------------------------------------- *
   THE SCORE AND ITS METER
   ---------------------------------------------------------------- */
.ashtar-done-meter {
  position: relative;
  display: block;
  width: 100%;
  max-width: 300px;
  height: 20px;
  margin: 4px auto 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #cbb08a, #b59468);
  box-shadow:
    inset 0 2px 4px rgba(90, 60, 25, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.ashtar-done-meterfill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe27a 0%, #ffb422 55%, #f08a00 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    0 0 10px rgba(255, 180, 40, 0.7);
}

.ashtar-done-best {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #7a4f22;
}

/* ---------------------------------------------------------------- *
   TONE LINES — story, retry, incomplete
   ---------------------------------------------------------------- */
.ashtar-done-storybadge,
.ashtar-done-retry,
.ashtar-done-incomplete {
  margin: 6px 0 0;
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.ashtar-done-storybadge {
  color: #1f6b2b;
  background: rgba(90, 190, 100, 0.20);
  border: 2px solid rgba(60, 150, 70, 0.45);
}

/* A failed attempt is never scolded. It says what the child can still do. */
.ashtar-done-retry {
  color: #8a4a10;
  background: rgba(255, 180, 60, 0.22);
  border: 2px solid rgba(220, 140, 30, 0.5);
}

.ashtar-done-incomplete {
  color: #7a3f3f;
  background: rgba(200, 120, 120, 0.18);
  border: 2px solid rgba(180, 90, 90, 0.45);
}

/* ---------------------------------------------------------------- *
   THE ANIMALS
   ---------------------------------------------------------------- */
.ashtar-done-animals { margin: 10px 0 2px; }

.ashtar-done-animalsh {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 900;
  color: #6b3a17;
}

.ashtar-done-animalrow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.ashtar-done-animal {
  width: 66px;
  padding: 5px 4px 4px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf4 0%, #f3e4c2 100%);
  border: 3px solid #c9973f;
  box-shadow: 0 4px 8px rgba(90, 55, 15, 0.28);
}

/* Already owned: the same picture in a calmer frame, never hidden. */
.ashtar-done-animal.is-owned {
  background: linear-gradient(180deg, #eef3ee 0%, #dbe4dc 100%);
  border-color: #9fb3a5;
}

.ashtar-done-animalart {
  display: block;
  width: 50px;
  height: 50px;
  margin: 0 auto 2px;
  border-radius: 12px;
  background: linear-gradient(160deg, #9fe58a 0%, #4aa14c 100%);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.ashtar-done-animal.is-owned .ashtar-done-animalart {
  background: linear-gradient(160deg, #dfe8e0 0%, #a9bfae 100%);
}

.ashtar-done-animalimg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ashtar-done-animalname {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #5a3a16;
}

/* ---------------------------------------------------------------- *
   THE BUTTONS — glossy game buttons, not web buttons
   ---------------------------------------------------------------- */
/* ALWAYS-VISIBLE ACTION FOOTER, INSIDE THE CARD.
   A flex child of the panel rather than `position: fixed` against the page, so
   it travels with the card and is never stranded when the overlay scrolls.
   Two compact columns instead of four tall rows: the primary action spans the
   full width, the rest pair up beneath it. */
/* A compact 2 x 2 grid. The earlier "primary action spans both columns" rule
   made the footer three rows tall, which is what pushed the last button below
   the fold on a 390 x 844 screen. All four actions now pair up evenly, so the
   whole footer is two short rows. A failed run renders three buttons and simply
   leaves the fourth cell empty. */
.ashtar-done-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
  /* The gesture bar lives here, never under the last button. */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 2px);
}

/* Sized so the whole card - score, stars, rewards and all three secondary
   buttons - fits a 390 x 844 phone without the last control being clipped.
   The panel still scrolls if a language runs long. */
.ashtar-done-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;              /* above the 44px touch-target minimum */
  padding: 9px 14px;
  border-radius: 15px;
  border: 3px solid rgba(0, 0, 0, 0.22);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
  color: #ffffff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.08s ease;
  /* The gloss: a light band across the top of every button. */
  position: relative;
  overflow: hidden;
}

.ashtar-done-btn::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  top: 4px;
  height: 42%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.ashtar-done-btn:active { transform: translateY(2px); }

.ashtar-done-btn:focus-visible {
  outline: 3px solid #fff3b0;
  outline-offset: 2px;
}

/* next adventure — the reward for passing */
.ashtar-done-btn.is-next {
  background: linear-gradient(180deg, #8ae86f 0%, #46b64c 55%, #2c8c38 100%);
  border-color: #1d6b2a;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 5px 0 #175a22, 0 8px 16px rgba(0, 0, 0, 0.35);
}

/* replay — always available, after success too */
.ashtar-done-btn.is-replay {
  background: linear-gradient(180deg, #ffd979 0%, #f5a623 55%, #d8800c 100%);
  border-color: #a35f06;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.20), 0 5px 0 #8a4d05, 0 8px 16px rgba(0, 0, 0, 0.33);
}

/* album */
.ashtar-done-btn.is-album {
  background: linear-gradient(180deg, #7cc4ff 0%, #3d8fe8 55%, #1f66c0 100%);
  border-color: #17509c;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 5px 0 #123f80, 0 8px 16px rgba(0, 0, 0, 0.33);
}

/* back to the map */
.ashtar-done-btn.is-book {
  background: linear-gradient(180deg, #fff3d8 0%, #f0dcae 55%, #dcc48c 100%);
  border-color: #a98a4e;
  color: #5a3a16;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 -4px 0 rgba(120, 85, 30, 0.20), 0 5px 0 #8d7440, 0 8px 16px rgba(0, 0, 0, 0.28);
}

/* ---------------------------------------------------------------- *
   REDUCED MOTION
   ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ashtar-done-btn { transition: none; }
  .ashtar-done-btn:active { transform: none; }
}

/* ------------------------------------------------------------------ *
 * THREE BUTTONS: TWO ON THE FIRST ROW, THE THIRD CENTRED BENEATH THEM.
 *
 * The actions row is a two-column grid, so an odd third button lands in column
 * one of the second row and sits hard against the edge. It is centred across
 * the full width instead, which is the only thing that changes here: the
 * button keeps its own colour, size, padding and action, and a four-button
 * story card matches nothing and is unaffected.
 * ------------------------------------------------------------------ */
.ashtar-done-actions > .ashtar-done-btn:nth-child(3):last-child {
  grid-column: 1 / -1;
  justify-self: center;
  width: auto;
  min-width: min(100%, 62%);
}
/* ==========================================================================
 * THE GROUP RESULT AND THE THREE-BUTTON ROW
 *
 * Added for the Animal Friends groups. The 100 challenge stages never send a
 * percentage, so their card renders exactly as before.
 * ========================================================================== */
.ashtar-done-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin: 2px 0 6px;
  padding: 8px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .12);
}
.ashtar-done-percent {
  font-size: clamp(26px, 8vw, 40px);
  font-weight: 1000;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.ashtar-done-score-stars { display: inline-flex; gap: 4px; }
.ashtar-done-score-star {
  font-size: clamp(20px, 5.4vw, 28px);
  line-height: 1;
  color: rgba(255, 255, 255, .38);
}
.ashtar-done-score-star.is-on {
  color: #ffd83d;
  text-shadow: 0 2px 0 #a86a00, 0 0 14px rgba(255, 216, 61, .8);
}
.ashtar-done-score-note, .ashtar-done-score-best {
  font-size: clamp(12px, 3.6vw, 15px);
  font-weight: 800;
  color: #eaf3ff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .55);
}
.ashtar-done-score-best { opacity: .82; }

/* THREE BUTTONS: two on the first row, the third centred below.
   Every button keeps a full 48px touch target and nothing scrolls. */
.ashtar-done-actions.is-tri {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  justify-items: stretch;
}
.ashtar-done-actions.is-tri > .ashtar-done-btn:nth-child(3) {
  grid-column: 1 / -1;
  justify-self: center;
  min-width: 58%;
}
.ashtar-done-actions.is-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
