@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-stretch: 75% 125%;
  font-display: swap;
}

/* The six approved colours (brand guidelines p.27). No others. */
:root {
  --forest: #404B3A;
  --brass: #A98852;    /* rules and small marks, never text on a light ground */
  --paprika: #C0442E;  /* a ground, not an ink; about a tenth of the surface */
  --oat: #F0E6D6;
  --bark: #43301F;
  --ink: #22211D;

  --band: max(10vh, 68px);
  --foot: 34px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
h1, p { margin: 0; }
img { display: block; max-width: 100%; }

body {
  background: var(--oat);
  color: var(--ink);
  font-family: "Fredoka", system-ui, sans-serif;
}

/* Phones and portrait screens: logo, pictures, band, footer */
.page {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;    /* nothing that is still flying in may add a scrollbar */
}

.mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 24px 30px;
  text-align: center;
}

.brand { position: relative; }
.logo { width: min(66vw, 340px); height: auto; }
.intro { display: none; }

.tagline {
  color: var(--forest);
  font-size: clamp(2rem, 9vw, 3rem);
  font-stretch: 85%;
  font-weight: 600;
  line-height: 1.08;
}
.tagline span { display: block; }
.tagline::before {
  content: "";
  display: block;
  width: 56px;
  height: 3px;
  margin: 26px auto 22px;
  background: var(--brass);
}

.table {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 14px;
  background: var(--forest);
}

/* The pictures carry their own lettering, so they are shown whole */
.stage {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 1600 / 899;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bark);
  box-shadow: 0 18px 36px -18px var(--ink);
  user-select: none;
}

/* main.js sweeps the new picture over the one before it */
.slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  visibility: hidden;
}
.slide.is-on { visibility: visible; z-index: 2; }
.slide.was-on { visibility: visible; z-index: 1; }

.picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 900px;
}
.picker[hidden] { display: none; }

.picker button {
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.thumb { position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.thumb:hover img, .thumb[aria-current="true"] img { opacity: 1; }
.thumb[aria-current="true"] { outline: 3px solid var(--brass); outline-offset: 2px; }
/* fills while the picture is on show */
.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: var(--brass);
  transform: scaleX(0);
  transform-origin: left;
}

.picker .play {
  display: grid;
  place-items: center;
  border: 1px solid var(--brass);
  color: var(--oat);
}
.play svg { width: 40%; height: 55%; fill: currentColor; }
.play .icon-play, .play.is-paused .icon-pause { display: none; }
.play.is-paused .icon-play { display: block; }

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

.soon {
  display: grid;
  place-items: center;
  min-height: var(--band);
  padding: 14px 20px;
  background: var(--paprika);
  color: #fff;
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-stretch: 90%;
  font-weight: 600;
  text-align: center;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 18px;
  min-height: var(--foot);
  padding: 4px 14px;
  background: var(--oat);
  color: var(--ink);
  font-size: .95rem;
  font-weight: 500;
  position: relative;
  z-index: 40;
}
.foot span + span { padding-left: 18px; border-left: 1px solid var(--brass); }
.foot a {
  color: inherit;
  font-weight: 600;
  text-decoration-color: var(--brass);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.foot a:focus-visible { outline: 3px solid var(--forest); outline-offset: 2px; }
/* narrow screens: the contact line sits above the credit line */
@media (max-width: 699px) {
  .foot { padding-block: 8px; }
  .foot .more { flex-basis: 100%; text-align: center; }
  .foot .more + span { padding-left: 0; border-left: 0; }
}

/* Tablets: the picker fits on one row */
@media (min-width: 600px) {
  .picker { grid-template-columns: repeat(8, 1fr); }
}

/* Upright tablets and short phones: tighter, so the footer stays on the screen */
@media (min-width: 600px) and (orientation: portrait) {
  .mark { padding: 24px 24px 20px; }
  .tagline::before { margin: 18px auto 16px; }
  .table { padding: 16px 14px; }
}
@media (orientation: portrait) and (max-height: 700px) {
  .mark { padding: 14px 20px 12px; }
  .logo { width: min(48vw, 220px); }
  .tagline { font-size: 1.75rem; }
  .tagline::before { margin: 10px auto 8px; }
  .table { gap: 10px; padding: 10px 14px; }
}

/* Laptops and other wide screens: everything on one screen */
@media (min-width: 640px) and (orientation: landscape) {
  .page {
    grid-template-columns: minmax(250px, 36%) 1fr;
    grid-template-rows: 1fr var(--band) auto;
  }
  .mark { padding: 32px 24px; }
  .logo { width: min(28vw, 460px, 62vh); }
  .tagline { font-size: clamp(1.75rem, min(3.6vw, 7.2vh), 3.6rem); }
  .table { gap: 18px; padding: 28px clamp(16px, 3vw, 56px); }
  /* as wide as the column allows without pushing the picker off the screen */
  .stage, .picker { max-width: max(420px, calc((100vh - var(--band) - var(--foot) - 150px) * 1600 / 899)); }
  .soon { grid-column: 1 / -1; padding-block: 8px; }
  .foot { grid-column: 1 / -1; }
}

/* A phone turned sideways */
@media (min-width: 640px) and (orientation: landscape) and (max-height: 500px) {
  :root { --band: 52px; --foot: 24px; }
  .foot { font-size: .8rem; padding-block: 2px; }
  .mark { padding: 12px 16px; }
  .logo { width: min(28vw, 46vh); }
  .tagline { font-size: 1.6rem; }
  .tagline::before { margin: 14px auto 12px; }
  .table { gap: 10px; padding: 12px 16px; }
  .stage, .picker { max-width: calc((100vh - var(--band) - var(--foot) - 90px) * 1600 / 899); }
  .picker { gap: 6px; }
  .soon { font-size: 1.4rem; }
}

/* ---- Opening: the logo writes itself and the oak leaf drifts down ---- */
@keyframes appear { from { opacity: 0; } }
@keyframes leave { to { visibility: hidden; } }
@keyframes write-ltr { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes write-rtl { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes fall {
  0%   { opacity: 0; transform: translate(16%, -75%) rotate(70deg); }
  12%  { opacity: 1; }
  35%  { transform: translate(-9%, -48%) rotate(-38deg); }
  62%  { transform: translate(6%, -22%) rotate(24deg); }
  84%  { transform: translate(-2%, -6%) rotate(-10deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes draw { from { transform: scaleX(0); } }
@keyframes up { from { opacity: 0; transform: translateY(26px); } }
@keyframes band { from { transform: translateY(100%); } }

/* Visitors who ask their device for less movement see the finished page at once */
@media (prefers-reduced-motion: no-preference) {
  .brand > .logo { animation: appear 1ms 2.4s both; }
  .intro { display: block; position: absolute; inset: 0; animation: leave 1ms 2.4s forwards; }
  .intro img { position: absolute; inset: 0; margin: auto; }
  .english { animation: write-ltr 1.1s .15s cubic-bezier(.45, .05, .35, 1) both; }
  .arabic  { animation: write-rtl .7s .8s ease-out both; }    /* Arabic is written right to left */
  .leaf    { animation: fall 1.55s .7s cubic-bezier(.4, .1, .5, 1) both; transform-origin: 30.4% 15.3%; }
  .tagline::before { animation: draw .5s 1.5s ease-out both; }
  .tagline span:nth-child(1) { animation: up .7s 1.6s cubic-bezier(.2, .7, .2, 1) both; }
  .tagline span:nth-child(2) { animation: up .7s 1.85s cubic-bezier(.2, .7, .2, 1) both; }
  .soon { animation: band .7s 2.1s cubic-bezier(.2, .7, .2, 1) both; }
}
