/* Sky on that Day - try-it-yourself star map page */

@font-face {
  font-family: "Cinzel";
  src: url("fonts/Cinzel.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

/* The other fonts a visitor can pick, one weight each. Made by
   tools/build_fonts.py and listed in js/fonts.js. */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/CormorantGaramond-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Jost";
  src: url("fonts/Jost-Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("fonts/Poppins-Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Bebas Neue";
  src: url("fonts/BebasNeue-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #0a1120;
  --panel: #111b2f;
  --panel-edge: rgba(255, 255, 255, 0.13);
  --ink: #e9edf5;
  --soft: #a3aec2;
  --gold: #c9a55e;
  --gold-ink: #17130a;
  --serif: "Cinzel", "Times New Roman", serif;
  --plain: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: radial-gradient(120% 70% at 50% 0%, #16223c 0%, var(--night) 60%) fixed var(--night);
  color: var(--ink);
  font: 16px/1.5 var(--plain);
  -webkit-text-size-adjust: 100%;
}

.top {
  padding: 22px 20px 0;
  text-align: center;
}

.brand {
  margin: 0;
  font: 400 15px/1 var(--serif);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
}

.page {
  display: grid;
  /* one column that may shrink: without this, wide pictures push the page
     past the edge of a phone */
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 14px 40px;
}

.intro {
  text-align: center;
}

.intro h1 {
  margin: 0 0 8px;
  font: 400 clamp(26px, 6vw, 40px) / 1.15 var(--serif);
  letter-spacing: 0.02em;
  text-wrap: balance;
}

.intro p {
  margin: 0 auto;
  max-width: 34em;
  color: var(--soft);
  text-wrap: pretty;
}

/* ---- the wall and the framed poster ---- */

.wall {
  display: grid;
  place-items: center;
  padding: 18px 14px 26px;
  border-radius: 16px;
  background: linear-gradient(165deg, #efebe4 0%, #dcd6cc 55%, #cbc4b8 100%);
}

/* A thin frame, like the ones in the mockup photos: each side is 6.5% of the
   print's width, about 1.4 cm on an A4 print.
     --side            that width as a share of the whole framed width
     --side-of-height  the same width as a share of the whole framed height
   To change the thickness, with t = side / print width:
     --side = t / (1 + 2t)      --side-of-height = t / (1.4145 + 2t)        */
.frame {
  --side: 5.75%;
  --side-of-height: 4.21%;
  position: relative;
  width: min(100%, 520px);
  padding: var(--side);
  background: var(--tone-left);
  box-shadow:
    0 1px 2px rgba(40, 28, 14, 0.3),
    0 20px 34px -12px rgba(40, 28, 14, 0.55);
  --grain-a: none;
}

.side {
  position: absolute;
  display: block;
  background: var(--grain-a), linear-gradient(var(--tone), var(--tone));
}

.side--top,
.side--bottom {
  left: 0;
  right: 0;
  height: 0;
  padding-bottom: var(--side);
}

.side--left,
.side--right {
  top: 0;
  bottom: 0;
  width: var(--side);
}

/* mitred corners: each side is cut at 45 degrees where it meets the next */
.side--top {
  top: 0;
  --tone: var(--tone-top);
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--side)) 100%, var(--side) 100%);
}

.side--bottom {
  bottom: 0;
  --tone: var(--tone-bottom);
  clip-path: polygon(var(--side) 0, calc(100% - var(--side)) 0, 100% 100%, 0 100%);
}

.side--left {
  left: 0;
  --tone: var(--tone-left);
  clip-path: polygon(0 0, 100% var(--side-of-height), 100% calc(100% - var(--side-of-height)), 0 100%);
}

.side--right {
  right: 0;
  --tone: var(--tone-right);
  clip-path: polygon(0 var(--side-of-height), 100% 0, 100% 100%, 0 calc(100% - var(--side-of-height)));
}

/* The moulding is flat, so the four sides differ only a little: light from
   the top left, just enough to show the corner joints. */
.frame[data-frame="black"] {
  --tone-top: #252729;
  --tone-left: #202224;
  --tone-right: #1a1b1d;
  --tone-bottom: #161718;
}

.frame[data-frame="white"] {
  --tone-top: #fbfaf7;
  --tone-left: #f4f1ec;
  --tone-right: #ebe7e0;
  --tone-bottom: #e3dfd6;
}

.frame[data-frame="wood"] {
  --tone-top: #d9ba8c;
  --tone-left: #d2b182;
  --tone-right: #c8a473;
  --tone-bottom: #c09b69;
}

/* Light wood. The grain is a small drawn-on-the-fly picture of long uneven
   streaks, running along each side the way a real moulding is cut. */
.frame[data-frame="wood"] .side--top,
.frame[data-frame="wood"] .side--bottom {
  --grain-a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='160'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.005 0.36' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.26 0 0 0 0 0.11 0.85 0 0 0 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

.frame[data-frame="wood"] .side--left,
.frame[data-frame="wood"] .side--right {
  --grain-a: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='640'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.36 0.005' numOctaves='3' seed='19' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.26 0 0 0 0 0.11 0.85 0 0 0 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* The frame sits around the print and never over it. */
.poster {
  position: relative;
  aspect-ratio: 2480 / 3508;
  overflow: hidden;
  background: #0b1424;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.32);
}

.poster__picture {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.poster__line {
  font-family: var(--serif);
  font-weight: 400;
  text-anchor: middle;
  fill: rgb(214, 224, 238);
}

.poster__line--title {
  fill: #fff;
}

.note {
  margin: 12px 4px 0;
  font-size: 13.5px;
  color: var(--soft);
  text-wrap: pretty;
}

/* ---- the choices ---- */

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 22px 18px;
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  background: var(--panel);
}

.field,
fieldset.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label,
legend {
  padding: 0;
  font: 400 12.5px/1.2 var(--serif);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

input[type="text"],
input[type="date"],
input[type="time"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  background: #0b1323;
  color: var(--ink);
  font: 16px/1.3 var(--plain);
}

#words {
  text-transform: uppercase;
}

/* a slider's label carries its current value on the right */
label:has(output) {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

label output {
  font: 13px/1.2 var(--plain);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  height: 34px;
  margin: 0;
  background: transparent;
  accent-color: var(--gold);
  cursor: pointer;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  font-size: 12.5px;
  color: var(--soft);
}

.hint a {
  color: var(--gold);
}

input:focus-visible,
.choice:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.hint {
  margin: -8px 0 0;
  font-size: 13px;
  color: var(--soft);
}

.field > .hint {
  margin: 0;
}

.combo {
  position: relative;
}

.combo ul {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 290px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  background: #0d1729;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.5);
}

.combo li {
  padding: 11px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.combo li[aria-selected="true"],
.combo li[role="option"]:hover {
  background: rgba(201, 165, 94, 0.2);
}

.combo .combo__none {
  color: var(--soft);
  cursor: default;
}

.designs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.frames,
.fonts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

/* each font's button shows its name in that font, in capitals like the poster */
.choice.choice--font {
  align-content: center;
  min-height: 48px;
  padding: 8px 2px;
  overflow: hidden;
  /* small enough that the longest name, MONTSERRAT, fits on a phone */
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.choice {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 8px 6px;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  font: 13px/1.2 var(--plain);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice:has(input:checked) {
  border-color: var(--gold);
  background: rgba(201, 165, 94, 0.12);
}

.choice--design {
  padding: 5px 5px 8px;
}

.choice--design img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.swatch {
  width: 100%;
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.swatch--black {
  background: linear-gradient(180deg, #2a2c2f, #121314);
}

.swatch--white {
  background: linear-gradient(180deg, #fdfcfa, #dcd7cd);
}

.swatch--wood {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='80'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.008 0.5' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.26 0 0 0 0 0.11 0.85 0 0 0 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #d9ba8c, #c09b69);
}

/* ---- message buttons ---- */

.contact {
  display: grid;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--panel-edge);
}

.contact__lead {
  margin: 10px 0 2px;
  color: var(--ink);
}

.contact__lead + .contact__lead {
  margin-top: 0;
  color: var(--soft);
}

.button {
  display: block;
  min-height: 48px;
  padding: 13px 16px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--gold);
  font: 600 15px/1.35 var(--plain);
  text-align: center;
  text-decoration: none;
}

.button--main {
  background: var(--gold);
  color: var(--gold-ink);
}

.button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.foot {
  padding: 0 20px 34px;
  text-align: center;
  font-size: 12.5px;
  color: #77839a;
}

.foot p {
  margin: 0 auto;
  max-width: 44em;
}

/* ---- wide screens: poster on the left, choices on the right ---- */

@media (min-width: 900px) {
  .page {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "stage intro"
      "stage controls";
    column-gap: 30px;
    align-items: start;
    padding-top: 22px;
  }

  /* the heading sits beside the poster, not above it, so the poster starts
     at the top of the page and can be as tall as the window */
  .intro {
    grid-area: intro;
    text-align: left;
  }

  .intro h1 {
    font-size: 30px;
  }

  .intro p {
    margin: 0;
  }

  .stage {
    grid-area: stage;
    position: sticky;
    top: 14px;
  }

  .controls {
    grid-area: controls;
  }

  .wall {
    padding: 26px 26px 34px;
  }

  /* as big as the column allows, but never taller than the window, so the
     whole framed poster stays in view while the choices scroll */
  .frame {
    width: min(100%, 560px, calc((100vh - 150px) / 1.367));
  }
}
