/* The story: cards laid over the island, between two dark bars, as at the pictures. Also the few
   lines of it that turn up on the chart and on the sheet at the end of an island. */

.story {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: 1fr auto;
  cursor: pointer;
  /* A veil round the edges, and a deeper one along the foot for the words to stand on. */
  background:
    linear-gradient(180deg, rgba(2, 12, 20, 0) 38%, rgba(2, 12, 20, 0.62) 62%, rgba(2, 12, 20, 0.86) 88%),
    radial-gradient(ellipse at 50% 42%, rgba(2, 12, 20, 0.08) 20%, rgba(2, 12, 20, 0.55) 100%);
  animation: story-veil 1.2s ease-out both;
}
.story.dark { background: radial-gradient(ellipse at 50% 42%, rgba(5, 20, 32, 0.95) 10%, rgba(2, 10, 18, 0.99) 100%); }
.story.is-ending, .modal.world-ended { background: #03060c; }
@keyframes story-veil { from { opacity: 0; } to { opacity: 1; } }

/* The bars. */
.story::before, .story::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 12vh;
  background: #02090f;
  transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: none;
}
.story::before { top: 0; transform: translateY(-100%); box-shadow: 0 10px 40px rgba(2, 9, 15, 0.8); }
.story::after { bottom: 0; transform: translateY(100%); box-shadow: 0 -10px 40px rgba(2, 9, 15, 0.8); }
.story.open::before, .story.open::after { transform: none; }

.story-stage { position: relative; grid-row: 1; }
.story-card {
  position: absolute;
  left: 50%;
  bottom: 17vh;
  width: min(760px, calc(100% - 40px));
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
  animation: story-in 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.story-card.out { animation: story-out 0.6s ease-in both; }
@keyframes story-in { from { opacity: 0; transform: translate(-50%, 18px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes story-out { from { opacity: 1; } to { opacity: 0; transform: translate(-50%, -10px); } }
.story-card p {
  margin: 0;
  font: 500 clamp(19px, 2.7vw, 31px) / 1.42 var(--serif);
  color: #fff6dc;
  text-wrap: balance;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.95), 0 0 26px rgba(2, 12, 20, 0.95), 0 0 60px rgba(2, 12, 20, 0.8);
}

/* One of the four has something to say. */
.story-card.says {
  grid-template-columns: auto minmax(0, 1fr);
  justify-items: start;
  align-items: center;
  gap: 22px;
  text-align: left;
  padding: 16px 24px 16px 16px;
  width: min(720px, calc(100% - 40px));
  background: linear-gradient(180deg, rgba(27, 40, 58, 0.9), rgba(11, 19, 30, 0.93));
  border: 1px solid var(--line-2);
  border-left: 8px solid var(--who, var(--gold));
  border-radius: 18px;
  box-shadow: var(--shadow), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.story-card.says img { width: clamp(88px, 15vw, 150px); height: auto; aspect-ratio: 1; display: block; border-radius: 14px; box-shadow: 0 0 0 1px var(--line-2); }
.story-card.says b { font: 700 12px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.story-card.says p { margin-top: 8px; font-style: italic; font-size: clamp(18px, 2.3vw, 27px); text-shadow: none; text-wrap: pretty; }

/* The lighthouse. */
.lh { width: clamp(120px, 22vh, 210px); height: auto; overflow: visible; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.6)); }
.lh-rock { fill: #1c2b33; stroke: #0a1218; stroke-width: 2; }
.lh-tower { fill: #d9d2bf; stroke: #0a1218; stroke-width: 2; }
.lh-band { fill: #a8433a; }
.lh-door { fill: #3a2a22; stroke: #0a1218; stroke-width: 1.5; }
.lh-deck, .lh-room { fill: #39444d; stroke: #0a1218; stroke-width: 2; }
.lh-lamp { fill: #16202a; }
.lh-roof { fill: #a8433a; stroke: #0a1218; stroke-width: 2; stroke-linejoin: round; }
.lh-vane { stroke: #0a1218; stroke-width: 2.5; stroke-linecap: round; }
.lh-sea { opacity: 0.9; }
.lh.lit .lh-lamp { fill: #fff3b0; animation: lh-lamp 2.4s ease-in-out infinite alternate; }
.lh-glow { fill: rgba(255, 226, 130, 0.5); filter: blur(10px); animation: lh-lamp 2.4s ease-in-out infinite alternate; }
.lh-beams { transform-origin: 100px 62px; animation: lh-sweep 7s ease-in-out infinite alternate; }
@keyframes lh-lamp { from { opacity: 0.75; } to { opacity: 1; } }
@keyframes lh-sweep { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }

/* The final destruction ends in empty space. There is no recovering shore beneath the cards. */
.end-world { width: clamp(230px, 43vh, 410px); max-width: 100%; height: auto; }
.end-flare { fill: #e66b27; filter: blur(17px); animation: end-light 5s ease-out both; }
.end-fragments path { fill: #20181a; stroke: #e8783c; stroke-width: 1.5; transform-origin: 160px 110px; animation: end-break 6s ease-out both; }
@keyframes end-break { from { transform: none; } to { transform: translate(var(--dx), var(--dy)) rotate(var(--turn)); opacity: .45; } }
@keyframes end-light { from { opacity: .8; } to { opacity: .05; } }

/* The shore the world started again on: burnt and smoking, and then the same shore at sunrise. */
.shore { width: clamp(240px, 50vh, 460px); max-width: 100%; height: auto; }
.sh-land { stroke: #0a1218; stroke-width: 2; stroke-linejoin: round; }
.ash .sh-land { fill: #14181c; stroke: #040608; }
.ash .sh-wreck { fill: #0b0d10; stroke: #040608; stroke-width: 1.4; stroke-linejoin: round; }
.ash .sh-wheel { fill: none; stroke: #0b0d10; stroke-width: 2.4; stroke-linecap: round; }
.ash .sh-cinders { fill: none; stroke: #ff8a3a; stroke-width: 1.6; stroke-linecap: round; animation: sh-flicker 1.7s ease-in-out infinite alternate; }
.ash .sh-smoke { fill: #454c55; opacity: 0.8; filter: blur(3.5px); transform-origin: 130px 112px; animation: sh-sway 9s ease-in-out infinite alternate; }
.ash .sh-sparks circle { fill: #ffb060; opacity: 0; animation: sh-fly 4.2s linear infinite; }
.ash .sh-glint { fill: none; stroke: #d2502c; stroke-width: 1.6; stroke-linecap: round; opacity: 0.5; animation: sh-flicker 2.2s ease-in-out infinite alternate; }
.dawn .sh-land { fill: #dcb97c; }
.dawn .sh-shade { fill: #bd975f; }
.dawn .sh-stone { fill: #93a0a8; stroke: #0a1218; stroke-width: 1; stroke-linejoin: round; }
.dawn .sh-sprout path { fill: #62b24c; stroke: #2c6a2a; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.dawn .sh-folk { fill: #3a2417; }
.dawn .sh-arm { fill: none; stroke: #3a2417; stroke-width: 1.7; stroke-linecap: round; }
.dawn .sh-stars { fill: #eaf2ff; opacity: 0.55; }
.dawn .sh-clouds { fill: #ffd9c2; opacity: 0.9; }
.dawn .sh-rays { fill: #ffe9a8; opacity: 0.2; transform-origin: 130px 121px; animation: sh-turn 90s linear infinite; }
.dawn .sh-sun { fill: #fff3bc; animation: sh-rise 3.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.dawn .sh-glow { animation: sh-glow 3.4s ease-out both; }
.dawn .sh-glint { fill: none; stroke: #fff1c0; stroke-width: 1.6; stroke-linecap: round; opacity: 0.85; animation: sh-flicker 2.6s ease-in-out infinite alternate; }
@keyframes sh-rise { from { transform: translateY(42px); } to { transform: none; } }
@keyframes sh-glow { from { opacity: 0.2; } to { opacity: 1; } }
@keyframes sh-turn { to { transform: rotate(360deg); } }
@keyframes sh-flicker { from { opacity: 0.4; } to { opacity: 0.95; } }
@keyframes sh-sway { from { transform: skewX(-4deg); } to { transform: skewX(5deg); } }
@keyframes sh-fly { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(7px, -54px); opacity: 0; } }

.story-foot {
  grid-row: 2;
  position: relative;
  z-index: 1;
  height: 12vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(14px, 3vw, 34px);
  color: var(--ink-3);
  font-size: 12.5px;
}
.story-foot .hint { flex: 1; }
.story-pips { display: flex; flex-wrap: wrap; max-width: 56%; gap: 6px; }
.story-pips i { width: 7px; height: 7px; border-radius: 50%; background: rgba(244, 236, 217, 0.22); transition: background 0.4s ease; }
.story-pips i.on { background: var(--gold); }
.story-foot .btn { color: var(--ink-2); }

/* The title screen's quieter buttons. */
.title-more { display: flex; gap: 6px; justify-content: center; margin-top: -6px; }
.title-more .btn { font-size: 13.5px; padding: 5px 12px; color: #f4ecd9; }
.title-more .btn .ic { width: 15px; height: 15px; vertical-align: -2px; margin-right: 5px; }

/* A line of the story on the chart, and on the sheet at the end of an island. */
.tale { font: italic 14.5px/1.45 var(--serif); color: #e9dfc6; margin: 2px 0 10px; text-wrap: pretty; }
.voyage .tale { grid-column: 1 / -1; margin: 0 0 8px; }
.voyage.locked .tale { display: none; }
.modal-card .tale { margin-top: 12px; padding-left: 12px; border-left: 3px solid var(--gold-2); font-size: 16px; }

/* Taken with no more people than each rival had. */
.even { display: inline-flex; align-items: center; color: var(--gold); margin-right: 3px; }
.even .ic { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .story::before, .story::after, .story-foot { height: 9vh; }
  .story-card { bottom: 13vh; }
  .story-card.says { gap: 14px; padding: 12px 16px 12px 12px; }
  .story-foot .hint { display: none; }
}
@media (max-height: 520px) {
  .lh, .shore, .end-world { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .end-flare, .end-fragments path { animation: none; }
}
