/* ==========================================================================
   The Song of Saoirse - pan flute stage
   --------------------------------------------------------------------------
   Only what this page needs. The typeface, palette, background, page
   container, title, knot and buttons all live in ../assets/base.css, which
   is loaded before this file.
   ========================================================================== */

:root {
  --pipe-max: 58px;   /* widest a pipe gets on a roomy screen */
}

.hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  min-height: 1.4em;
  text-align: center;
  transition: color 180ms ease;
}

.hint.is-wrong { color: var(--leas-soft); }

/* --------------------------------------------------------------------------
   Config warning - only ever seen by the owner while setting up
   -------------------------------------------------------------------------- */

.config-warning {
  width: 100%;
  border: 1px solid #ffb4b4;
  background: #3a1030;
  color: #ffe2e2;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.86rem;
  line-height: 1.45;
}
.config-warning b { display: block; margin-bottom: 4px; }
.config-warning ul { margin: 0; padding-left: 18px; }

/* --------------------------------------------------------------------------
   Played-note slots
   -------------------------------------------------------------------------- */

.slots-wrap { width: 100%; }

.slots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.slot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(182, 129, 255, 0.4);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-variant-numeric: lining-nums tabular-nums;
  color: transparent;
  transition: background 200ms ease, box-shadow 200ms ease,
              border-color 200ms ease, color 200ms ease;
}

/* Filled slots carry BOTH a glow and the note text, so colour is never
   the only signal. */
.slot.is-filled {
  border-color: var(--leas-soft);
  background: rgba(182, 129, 255, 0.22);
  box-shadow: 0 0 14px rgba(182, 129, 255, 0.5);
  color: #fff;
}

.slot.is-wrong {
  border-color: #ffc9c9;
  background: rgba(255, 150, 150, 0.14);
  box-shadow: 0 0 12px rgba(255, 160, 160, 0.4);
  animation: flicker 700ms steps(2, end) 2;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  25%      { opacity: 0.25; }
  50%      { opacity: 0.9; }
  75%      { opacity: 0.2; }
}

/* --------------------------------------------------------------------------
   The flute - the one bold thing on the page
   -------------------------------------------------------------------------- */

.flute-wrap {
  /* Breaks out of the page gutter so the flute gets the full screen width.
     Eight pipes need every pixel on a narrow phone. */
  width: calc(100% + var(--gutter) * 2);
  margin-inline: calc(var(--gutter) * -1);
  display: flex;
  justify-content: center;
  flex: 1 1 auto;
  align-items: center;
}

.flute {
  position: relative;
  width: 100%;
  max-width: 430px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 10px 5px 16px;
  border-radius: 12px;
  /* A breath of warmth behind the instrument. */
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.5));
}

.pipe {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  /* Share the width out evenly. min-width:0 is what stops eight pipes from
     bursting out of a narrow screen and getting clipped at the edge. */
  flex: 1 1 0;
  min-width: 0;
  max-width: var(--pipe-max);
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 7px 7px 5px 5px;
  font: inherit;
  color: var(--bore);
  /* Honey-toned wood: lit left edge, shadowed right, fine grain. */
  background-image:
    /* cross grain, the faint rings of a cut cane */
    repeating-linear-gradient(
      177deg,
      rgba(86, 48, 20, 0.10) 0px,
      rgba(86, 48, 20, 0) 3px,
      rgba(86, 48, 20, 0.06) 7px,
      rgba(86, 48, 20, 0) 13px),
    /* lengthwise grain */
    repeating-linear-gradient(
      90deg,
      rgba(86, 48, 20, 0.07) 0px,
      rgba(86, 48, 20, 0) 2px,
      rgba(255, 226, 190, 0.05) 4px,
      rgba(86, 48, 20, 0) 7px),
    /* the barrel: lit from the left, rolling off to shadow on both edges.
       The highlight is deliberately soft - a hard band reads as metal. */
    linear-gradient(
      90deg,
      var(--wood-dark) 0%,
      var(--wood-mid) 15%,
      var(--wood) 33%,
      var(--wood-lit) 44%,
      var(--wood) 60%,
      var(--wood-mid) 82%,
      var(--wood-dark) 100%);
  box-shadow:
    inset 0 -6px 10px rgba(0, 0, 0, 0.32),
    0 1px 0 rgba(255, 220, 180, 0.18);
  transition: transform 110ms ease, box-shadow 220ms ease, filter 220ms ease;
}

/* The open bore at the top of each pipe. */
.pipe::before {
  content: "";
  position: absolute;
  top: 4px;
  right: 5px;
  left: 5px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, #4a2a12 0%, var(--bore) 70%);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.75);
}

.pipe-label {
  position: absolute;
  font-variant-numeric: lining-nums tabular-nums;
  left: 0;
  right: 0;
  bottom: 9px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #46280f;
  text-shadow: 0 1px 0 rgba(255, 224, 186, 0.45);
  pointer-events: none;
}

.pipe:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.pipe.is-sounding {
  transform: translateY(2px);
  filter: brightness(1.12);
  box-shadow:
    inset 0 -4px 8px rgba(0, 0, 0, 0.28),
    0 0 22px 5px rgba(182, 129, 255, 0.75);
}

/* Binding cords lashing the pipes together. */
.cord {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  /* Sits ABOVE the pipes, because a binding cord is lashed over the outside.
     Behind them it was invisible. */
  z-index: 2;
  background:
    linear-gradient(180deg,
      rgba(255, 224, 180, 0.30) 0%,
      rgba(0, 0, 0, 0.28) 55%,
      rgba(0, 0, 0, 0.45) 100%),
    repeating-linear-gradient(
      64deg,
      #7d6139 0px, #7d6139 3px,
      #513c22 3px, #513c22 6px);
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* Both cords sit high enough to cross even the shortest pipe. */
.cord-upper { top: 15%; }
.cord-lower { top: 30%; }


/* --------------------------------------------------------------------------
   Léas canvas
   -------------------------------------------------------------------------- */

#leas {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Above the reveal's backdrop (z-index 3) but below its text (z-index 5),
     so the light keeps swirling behind the coordinates. */
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 700ms ease;
}

#leas.is-lit { opacity: 1; }

/* --------------------------------------------------------------------------
   The reveal
   -------------------------------------------------------------------------- */

.reveal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 20px)
    var(--gutter)
    calc(env(safe-area-inset-bottom, 0px) + 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Near-solid. This is the one screen a finder reads at arm's length in
     daylight, so legibility beats seeing the flute through it. */
  background: radial-gradient(95% 75% at 50% 42%,
              rgba(20, 13, 52, 0.965) 0%, rgba(6, 4, 20, 0.995) 100%);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  transition: opacity 900ms ease;
}

.reveal.is-open { opacity: 1; }
.reveal[hidden] { display: none; }

.reveal-inner {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 420px;
  text-align: center;
  margin: auto;
}

.reveal-heading {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 7.5vw, 2.2rem);
  margin: 0 0 22px;
  color: #f6efff;
  text-shadow: 0 0 22px rgba(182, 129, 255, 0.55);
}

.prize { margin-bottom: 26px; }

.prize-label {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Big, high contrast, tabular - meant to be read outdoors at arm's length. */
.prize-value {
  margin: 0;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.coords { font-size: clamp(1.35rem, 6.6vw, 1.85rem); letter-spacing: 0.01em; }

.code {
  font-size: clamp(2.1rem, 11vw, 3rem);
  letter-spacing: 0.14em;
  text-shadow: 0 0 20px rgba(182, 129, 255, 0.5);
}

.copy-status {
  display: block;
  margin-top: 8px;
  min-height: 1.3em;
  font-size: 0.85rem;
  color: var(--leas-soft);
}

.nan {
  margin: 0 0 26px;
  padding: 16px 18px;
  border-left: 2px solid rgba(182, 129, 255, 0.55);
  text-align: left;
  font-style: italic;
  color: #ded6ff;
  font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Narrow phones: give up a little thumb room rather than scroll sideways.
   The pipes stay tall, so the touch AREA is still generous.
   -------------------------------------------------------------------------- */

@media (max-width: 389px) {
  :root { --gutter: 10px; }
  .flute { gap: 2px; padding-inline: 3px; }
  .pipe-label { font-size: 0.74rem; }
}

@media (min-width: 480px) {
  .slot { width: 46px; height: 46px; font-size: 0.9rem; }
}

/* Short landscape screens: keep the flute from overflowing. */
@media (orientation: landscape) and (max-height: 520px) {
  .page { gap: 12px; padding-top: 14px; }
  .knot { margin: 6px auto; height: 22px; }
  .intro { display: none; }
}


/* --------------------------------------------------------------------------
   Reduced motion: the swirl becomes a plain fade, nothing pulses or flickers.
   The blanket rule that stops animations is in base.css.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  /* Keep the reveal's fade, just make it brisk rather than instant. */
  .reveal { transition: opacity 240ms ease !important; }
  #leas { display: none; }
}
