/* The home page of the Spark & Siege world (index.html): the world's name, then its two games as one painted horizon,
   the first game's battlements and Spellscript's tower joined along a slanted gold seam. Each painting is a link to
   its game. On a phone the seam lies across the screen and the paintings stack; on a wider screen they stand side by
   side. The header and footer are in site-frame.css. */
@font-face {
  font-family: "Alegreya";
  src: url("fonts/Alegreya-Variable.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("fonts/AlegreyaSans-Medium.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* --night, --ink, --muted, --gold, --hair and .wrap are also read by site-frame.css for the header and footer. */
  --night: #12151c;
  --ink: #f6efdf;
  --muted: #b9b8b9;
  --gold: #f3cb89;
  --hair: #8f754e;
  --gutter: clamp(18px, 4vw, 52px);
  --max: 1176px;
  --seam-phone-px: 17px;              /* how far the seam drops across a phone's width */
  --seam-wide-lean: clamp(38px, 6vw, 82px); /* how far it leans across the spread on a wider screen */
  --seam-gap-px: 1px;                 /* the gold sliver left between the two scenes' clip-paths */
  --scene-phone-height: clamp(244px, 59vw, 350px);
  --scene-wide-height: clamp(340px, 35vw, 470px);
  --arrow-px: 34px;
  --hover-zoom: 1.025;                /* a painting leans in a little under the pointer */
  --hover-zoom-seconds: 0.55s;
  /* Spellscript's painting is a tall phone picture; laid across a phone's width its tower would be a sliver at the
     edge, so on phones it is drawn larger, held on the tower. */
  --tower-phone-zoom: 1.3;
  --tower-phone-anchor: 77% 55%;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--night); color: var(--ink);
  font: 500 1.0625rem/1.4 "Alegreya Sans", system-ui, sans-serif;
}
h1, h2, p { margin: 0; }
img { display: block; }
.wrap { width: min(calc(100% - 2 * var(--gutter)), var(--max)); margin-inline: auto; }
a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- The world's name ---------- */
main { background: radial-gradient(ellipse at 50% 18%, #272428, #171920 52%, var(--night) 86%); }
.title-block { text-align: center; padding: 25px 14px 23px; }
.title-block h1 { font: 500 clamp(3.1rem, 10vw, 5.9rem)/1.04 "Alegreya", Georgia, serif; letter-spacing: -0.049em; }
/* "The world of" sits above the name in small caps, between two gilt arrow-rules. */
.pretitle {
  display: flex; align-items: center; justify-content: center; gap: 0.9rem; margin-bottom: 4px;
  color: var(--gold); font: 500 0.7rem/1.15 "Alegreya Sans", system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: 0.22em;
}
.pretitle::before, .pretitle::after {
  content: ""; height: 5px; width: clamp(31px, 5vw, 62px);
  background: linear-gradient(to right, transparent, #c7a26d);
  clip-path: polygon(0 46%, 90% 46%, 95% 0, 100% 50%, 95% 100%, 90% 66%, 0 66%);
}
.pretitle::after { transform: rotate(180deg); }
.amp { color: var(--gold); font-weight: 400; }
.title-block p { margin-top: 7px; color: #d4c9bb; font-size: clamp(0.98rem, 1.4vw, 1.18rem); }

/* ---------- The horizon: two scenes cut along one seam ---------- */
/* The gold behind the scenes shows through the gap their clip-paths leave (--seam-gap-px), and that sliver is the seam. */
.horizon {
  --cut: var(--seam-phone-px);
  display: flex; flex-direction: column; position: relative; isolation: isolate;
  max-width: var(--max); margin-inline: auto;
  border-block: 1px solid var(--hair); background: #d0b18b;
}
.scene {
  position: relative; isolation: isolate; display: flex; align-items: end;
  min-height: var(--scene-phone-height);
  background: var(--land); color: #fff4df; text-decoration: none;
}
/* Each scene names the ground its caption fades into (--land), its arrow's colour (--glint) and where its painting
   is held when cropped (--focus). */
.wall {
  --land: #241714; --glint: #f8d693; --focus: 85% 45%;
  padding-bottom: var(--cut);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), 0 100%);
}
.tower {
  --land: #191223; --glint: #e7c4ed; --focus: 74% 36%;   /* high enough that the zoomed spire clears the seam, low enough to keep its windows */
  margin-top: calc(0px - var(--cut));
  clip-path: polygon(0 calc(var(--cut) + var(--seam-gap-px)), 100% var(--seam-gap-px), 100% 100%, 0 100%);
}
.painting, .scene::after { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; }
.painting { object-fit: cover; object-position: var(--focus); }
.tower .painting { transform: scale(var(--tower-phone-zoom)); transform-origin: var(--tower-phone-anchor); }
/* The foot of each painting darkens into its ground so the caption reads over any part of the picture. */
.scene::after {
  content: "";
  background: linear-gradient(to top, var(--land), rgba(14, 13, 20, 0.83) 12%, rgba(14, 13, 20, 0.35) 34%, transparent 59%);
}
.caption {
  width: 100%; padding: 22px var(--gutter) 15px;
  display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: center;
}
.tower .caption { padding-bottom: 21px; }   /* the tower has no seam below it to push its caption up, so it needs its own room */
.caption h2 { font: 600 clamp(2.35rem, 6vw, 3.85rem)/1 "Alegreya", Georgia, serif; letter-spacing: -0.045em; }
.caption p { grid-column: 1; color: #fff0e0; font-size: clamp(1rem, 1.52vw, 1.18rem); line-height: 1.25; }

/* A ringed arrow, drawn in CSS: a shaft (::before) and a head (::after). */
.arrow {
  grid-area: 1 / 2 / span 2; position: relative; width: var(--arrow-px); aspect-ratio: 1;
  color: var(--glint); border: 1px solid currentColor; border-radius: 50%;
}
.arrow::before, .arrow::after { content: ""; position: absolute; top: 50%; left: 50%; }
.arrow::before { width: 13px; height: 1.5px; background: currentColor; transform: translate(-50%, -50%); }
.arrow::after {
  width: 6px; height: 6px; border: solid currentColor; border-width: 1.5px 1.5px 0 0;
  transform: translate(-15%, -50%) rotate(45deg);
}
.scene:hover .arrow, .scene:focus-visible .arrow { color: var(--land); background: var(--glint); border-color: var(--glint); }
.scene:focus-visible h2 { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.12em; }

/* A wider screen: the scenes stand side by side and the seam leans from top to bottom. */
@media (min-width: 700px) {
  .title-block { padding-block: clamp(24px, 3vw, 42px) clamp(20px, 2vw, 32px); }
  .pretitle { font-size: 0.78rem; margin-bottom: 5px; }
  .horizon {
    --cut: var(--seam-wide-lean);
    flex-direction: row; width: calc(100% - 2 * var(--gutter));
    border: 1px solid var(--hair); margin-bottom: 10px;
  }
  .scene { flex: 1 1 0; min-width: 0; min-height: var(--scene-wide-height); }
  .wall {
    --focus: 83% center;
    padding-bottom: 0;
    clip-path: polygon(0 0, 100% 0, calc(100% - var(--cut)) 100%, 0 100%);
  }
  .tower {
    --focus: 74% 41%;
    margin-top: 0; margin-left: calc(0px - var(--cut));
    clip-path: polygon(calc(var(--cut) + var(--seam-gap-px)) 0, 100% 0, 100% 100%, var(--seam-gap-px) 100%);
  }
  .tower .painting { transform: none; }
  .caption, .tower .caption { padding: 25px clamp(24px, 2.8vw, 42px) 29px; }
  .wall .caption { padding-right: calc(var(--cut) + 15px); }
  .tower .caption { padding-left: clamp(34px, 3.6vw, 57px); }
  .arrow { width: clamp(36px, 3.6vw, 47px); }
  @media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .painting { transition: transform var(--hover-zoom-seconds) ease; }
    .scene:hover .painting { transform: scale(var(--hover-zoom)); }
  }
}
