/* ============================================================================
   St. George's School — Virtual Tour landing page
   Wording and links live in config.js. This file controls the look.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */

:root {
  --accent: #CE0E2D;                       /* overridden from config.js */
  --accent-bright: color-mix(in srgb, var(--accent) 82%, white);

  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.76);
  --ink-faint: rgba(255, 255, 255, 0.55);

  --glass: rgba(255, 255, 255, 0.08);
  --glass-strong: rgba(255, 255, 255, 0.13);
  --hairline: rgba(255, 255, 255, 0.18);
  --hairline-bright: rgba(255, 255, 255, 0.38);

  --radius-panel: 32px;
  --radius-card: 20px;

  --shadow-panel: 0 32px 80px -24px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 12px 32px -12px rgba(0, 0, 0, 0.45);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);      /* Apple-ish ease-out */
  --ease-spring: cubic-bezier(0.34, 1.32, 0.64, 1);

  --gutter: clamp(1.25rem, 4vw, 3rem);

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display",
          "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
}

/* --- Reset ---------------------------------------------------------------- */

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

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: #0f1b16;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

ul { list-style: none; margin: 0; padding: 0; }


/* --- Background photograph ------------------------------------------------ */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  /* Tiny blurred placeholder so the page never flashes black. */
  background-color: #12241d;
  background-image: url("data:image/webp;base64,UklGRgQBAABXRUJQVlA4IPgAAABwBgCdASogABwAPt1eqU4opSOiMBgIARAbiWMAnTLa/QOWGvj0NhxkvJnoIZ2fCg9Gl1Uj1FGrT9MdBoAA/mOGkT8VSx+TfbKJW2k4zbgGK5+gVlLvc11AYu0wR+0l6znl2I3RKx2UeMakmINuLY4FwVnzyBCUHUnPqMz7k+mDchg/Sx8TjIKgTFQ1a7A031W12u5bNWRJWkrk0MmzoAklEw6dF5m8wj7z3YdQftyYj64A553bQy3XjQAN+QmfsLnN9q6wD0a969YgZhCgy/NZ2P48T5mf7hWDS/MGSXr1aaZdaIU33cQlKjtHsOfk4FeKEhxzP1AAAA==");
  background-size: cover;
  background-position: center;
}

.backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 50%;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 1.1s var(--ease);
  will-change: opacity, transform;
}

.backdrop img.is-loaded { opacity: 1; }

/* Slow, almost imperceptible drift. Toggled from config.js. */
.backdrop.zoom img.is-loaded {
  animation: drift 46s var(--ease) forwards;
}

@keyframes drift {
  from { transform: scale(1.06); }
  to   { transform: scale(1.16); }
}

/* Legibility scrim: dark at the edges, softly lit behind the panel. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 90% at 50% 45%,
      rgba(6, 14, 11, 0.10) 0%,
      rgba(6, 14, 11, 0.42) 48%,
      rgba(4, 10, 8, 0.78) 100%),
    linear-gradient(to bottom,
      rgba(4, 10, 8, 0.42) 0%,
      rgba(4, 10, 8, 0.06) 30%,
      rgba(4, 10, 8, 0.20) 66%,
      rgba(4, 10, 8, 0.72) 100%);
}


/* --- Layout --------------------------------------------------------------- */

.stage {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.25rem, 3vh, 2rem);
  padding:
    calc(var(--gutter) + env(safe-area-inset-top))
    calc(var(--gutter) + env(safe-area-inset-right))
    calc(var(--gutter) + env(safe-area-inset-bottom))
    calc(var(--gutter) + env(safe-area-inset-left));
}


/* --- Glass panel ---------------------------------------------------------- */

.panel {
  width: min(100%, 46rem);
  padding: clamp(1.75rem, 4vw, 3rem);
  border-radius: var(--radius-panel);
  background: var(--glass);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-panel), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

/* Browsers without backdrop blur get a solid, still-legible panel. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel { background: rgba(10, 20, 16, 0.68); }
  .tour  { background: rgba(255, 255, 255, 0.10); }
}


/* --- Headline ------------------------------------------------------------- */

.intro {
  text-align: center;
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}

.logo {
  height: clamp(2.75rem, 7vw, 4rem);
  width: auto;
  margin: 0 auto clamp(1rem, 2.5vw, 1.5rem);
}

.eyebrow {
  margin: 0 0 0.6em;
  font-size: clamp(0.75rem, 1.6vw, 0.875rem);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

.title {
  margin: 0;
  font-size: clamp(2.125rem, 6.5vw, 4rem);
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.45);
}

.subtitle {
  margin: clamp(0.75rem, 2vw, 1.1rem) auto 0;
  max-width: 34ch;
  font-size: clamp(1rem, 2.2vw, 1.1875rem);
  line-height: 1.5;
  font-weight: 400;
  color: var(--ink-soft);
  text-wrap: pretty;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.45);
}


/* --- Tour buttons --------------------------------------------------------- */

.tours {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: clamp(0.75rem, 1.6vw, 1rem);
}

/* Each tour is a single link. Audio-guided vs self-guided is asked inside the
   tour instead, where the click can also unlock audio playback. */
.tour {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.75rem;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-card);
  background: var(--glass-strong);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  transition:
    transform 0.35s var(--ease-spring),
    border-color 0.3s var(--ease),
    box-shadow 0.35s var(--ease),
    background-color 0.3s var(--ease);
}

/* Accent wash that fills in from the left on hover. */
.tour::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg,
    var(--accent) 0%,
    color-mix(in srgb, var(--accent) 74%, #000) 100%);
  opacity: 0;
  transform: translateX(-8%);
  transition: opacity 0.32s var(--ease), transform 0.42s var(--ease);
}

.tour-text {
  flex: 1 1 auto;
  min-width: 0;
}

.tour-label {
  display: block;
  font-size: clamp(1rem, 1.9vw, 1.0625rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.tour-description {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  font-weight: 400;
  color: var(--ink-faint);
  transition: color 0.3s var(--ease);
}

.tour-arrow {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--ink-faint);
  transition: transform 0.35s var(--ease-spring), color 0.3s var(--ease);
}

@media (hover: hover) {
  .tour:hover {
    transform: translateY(-3px);
    border-color: var(--hairline-bright);
    box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.6);
  }
  .tour:hover::before { opacity: 1; transform: translateX(0); }
  .tour:hover .tour-description { color: rgba(255, 255, 255, 0.85); }
  .tour:hover .tour-arrow { color: #fff; transform: translateX(4px); }
}

.tour:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  border-color: transparent;
}
.tour:focus-visible::before { opacity: 1; transform: translateX(0); }
.tour:focus-visible .tour-arrow { color: #fff; }

.tour:active {
  transform: scale(0.985);
  transition-duration: 0.08s;
}


/* --- Footer --------------------------------------------------------------- */

.footer {
  margin: 0;
  text-align: center;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

.footer a {
  color: inherit;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-underline-offset: 0.2em;
  transition: color 0.25s var(--ease), text-decoration-color 0.25s var(--ease);
}

.footer a:hover,
.footer a:focus-visible {
  color: #fff;
  text-decoration-color: currentColor;
}

.footer a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 4px;
}


/* --- Entrance animation ---------------------------------------------------
   Deliberately brief. This page is a return destination: visitors come back to
   it every time they press Home or Menu inside a tour, so the whole sequence
   finishes in well under a second even on the slowest item. */

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.45s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 45ms + 60ms);
}

@keyframes rise {
  to { opacity: 1; transform: none; }
}

/* Set on the <html> element before first paint when the visitor is arriving
   back from a tour. Everything appears at once, already settled. */
.no-intro .reveal {
  opacity: 1;
  transform: none;
  animation: none;
}

.no-intro .backdrop img { transition: none; }
.no-intro .backdrop.zoom img.is-loaded { animation: none; }


/* --- Fallback / error message --------------------------------------------- */

.noscript,
.panel .config-error {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-card);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--hairline);
  text-align: center;
  line-height: 1.5;
  color: #fff;
}
.noscript { position: fixed; inset-inline: 1rem; bottom: 1rem; }


/* --- Narrow screens ------------------------------------------------------- */

@media (max-width: 30rem) {
  :root { --radius-panel: 26px; --radius-card: 16px; --gutter: 1rem; }

  .stage { gap: 0.75rem; }
  .panel {
    padding: 1.25rem 1.125rem;
    background: rgba(255, 255, 255, 0.07);
  }
  .intro { margin-bottom: 1.125rem; }
  .title { font-size: 2rem; }
  .subtitle { margin-top: 0.6rem; }

  .tours { gap: 0.5rem; }
  .tour { padding: 1rem 1.125rem; }
}

/* Shorter phones held upright: trim spacing so all four tours fit on screen. */
@media (max-height: 44rem) and (orientation: portrait) {
  :root { --gutter: 0.875rem; }

  .intro { margin-bottom: 1.125rem; }
  .subtitle { margin-top: 0.5rem; }
  .tour { padding: 0.85rem 1.125rem; }
}

/* Short / landscape phones: compress so everything still fits on one screen. */
@media (max-height: 34rem) and (orientation: landscape) {
  :root { --gutter: 0.625rem; }

  .stage { gap: 0.5rem; }
  .panel { padding: 0.875rem 1.125rem; }
  .intro { margin-bottom: 0.5rem; }
  .title { font-size: clamp(1.5rem, 4vw, 2rem); }
  .eyebrow { margin-bottom: 0.4em; }
  .subtitle { display: none; }

  .tours { gap: 0.375rem; }
  .tour { min-height: 0; padding: 0.7rem 0.9rem; }
  .tour-description { display: none; }
}


/* --- Accessibility preferences -------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .backdrop img { transform: none; }
  .backdrop.zoom img.is-loaded { animation: none; transform: none; }
}

@media (prefers-contrast: more) {
  .panel { background: rgba(6, 14, 11, 0.86); }
  .tour  { background: rgba(6, 14, 11, 0.8); border-color: rgba(255, 255, 255, 0.6); }
  .subtitle, .tour-description { color: #fff; }
  .footer { color: rgba(255, 255, 255, 0.85); }
}


/* --- Print ---------------------------------------------------------------- */

@media print {
  .backdrop, .scrim { display: none; }
  body { color: #000; background: #fff; }
  .panel { background: none; border: none; box-shadow: none; backdrop-filter: none; }
  .tour { border: 1px solid #999; background: none; color: #000; }
  .tour::after { content: " (" attr(href) ")"; font-size: 0.7rem; color: #555; }
}
