/* =========================================================
   Moonlit gallery — shared styles
   Everything readable is DOM. The canvas only carries atmosphere.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Marcellus&family=Jost:wght@300;400;500&display=swap');

:root {
  /* Palette sampled from the artwork itself */
  --ink:        #05080f;   /* page black-blue                      */
  --deep:       #0a1320;   /* night sky                            */
  --water:      #132538;   /* lake                                 */
  --moon:       #f2e4c4;   /* ivory moon, brightest thing on page  */
  --lantern:    #d99a4e;   /* pavilion window light                */
  --gold:       #b9975b;   /* hairline frames, underlines          */
  --text:       #e9e4d9;
  --muted:      #93a1b4;
  --glass:      rgba(11, 20, 33, 0.55);
  --glass-edge: rgba(201, 180, 130, 0.34);

  --display: 'Marcellus', 'Didot', 'Bodoni MT', Georgia, serif;
  --ui: 'Jost', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;

  --pad: clamp(1.25rem, 3.4vw, 3rem);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--ui);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }
body.scrolls { overflow-y: auto; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 4px;
}

/* ---------- stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* A still frame of the scene, painted in CSS, so the page is never black
   while textures load and never empty if WebGL is unavailable. */
#stage-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #070b14;
  background-image: url('../assets/luna-background-clean.png');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* ---------- overlay chrome ---------- */

.ui {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  padding: var(--pad);
  display: grid;
  grid-template-rows: auto 1fr auto;
  pointer-events: none;
}

.ui > * { pointer-events: auto; }

/* Scrims: the moon is bright enough to swallow text, so top and bottom get a
   soft gradient that keeps the menu and the rail legible over anything. */
.ui::before,
.ui::after {
  content: none;
  position: fixed;
  left: 0; right: 0;
  z-index: -1;
  pointer-events: none;
}
.ui::before { top: 0; height: clamp(100px, 15vh, 180px); background: linear-gradient(180deg, rgba(4,8,15,0.48), rgba(4,8,15,0)); }
.ui::after  { bottom: 0; height: clamp(90px, 13vh, 160px); background: linear-gradient(0deg, rgba(4,8,15,0.58), rgba(4,8,15,0)); }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.mark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--display);
  font-size: clamp(1rem, 1.25vw, 1.16rem);
  letter-spacing: 0.32em;
  color: var(--text);
}

.mark::before {
  content: '';
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--moon);
  box-shadow: 0 0 16px rgba(242, 228, 196, 0.55);
}

.nav {
  display: flex;
  gap: clamp(1.2rem, 3vw, 3rem);
  font-size: clamp(1rem, 1.35vw, 1.2rem);
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--text);
  background: rgba(5, 8, 15, 0.72);
  padding: 0.5rem 0.85rem;
}

.nav a {
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(233, 228, 217, 0.3);
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.8);
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.nav a:hover { border-color: var(--moon); }
.nav a[aria-current='page'] { border-color: var(--gold); border-bottom-width: 2px; }

/* ---------- hero ---------- */

.hero {
  align-self: start;
  max-width: 38vw;
  margin-top: clamp(1.2rem, 5vh, 3.5rem);
}

.hero h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.8rem, 5.4vw, 5rem);
  line-height: 0.98;
  margin: 0;
  text-wrap: balance;
  text-shadow: 0 2px 40px rgba(0, 0, 0, 0.6);
}

.hero p {
  margin: 1.1rem 0 0;
  max-width: 34ch;
  font-size: 0.98rem;
  letter-spacing: 0.13em;
  color: var(--muted);
}

/* ---------- footer rail ---------- */

.rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: clamp(0.86rem, 1.05vw, 1rem);
  letter-spacing: 0.12em;
  color: var(--text);
}

/* One tick per work — the only way to move through thirty-odd pictures
   without pressing an arrow thirty times. */
.ticks { display: flex; align-items: flex-end; gap: 1px; }

.tick {
  width: 10px; height: 22px;
  padding: 0; border: 0; background: none;
  position: relative; cursor: pointer;
}
.tick::before {
  content: '';
  position: absolute;
  left: 50%; bottom: 0;
  width: 1px; height: 9px;
  background: rgba(233, 228, 217, 0.34);
  transition: height 0.35s var(--ease), background 0.35s var(--ease), width 0.35s var(--ease);
}
.tick.photo::before { background: rgba(185, 151, 91, 0.55); }
.tick:hover::before { height: 15px; background: var(--moon); }
.tick[aria-current='true']::before { height: 21px; width: 2px; background: var(--gold); }

.rail-contact { display: flex; align-items: baseline; gap: clamp(0.9rem, 2vw, 1.8rem); }
.rail-contact a { border-bottom: 1px solid rgba(185, 151, 91, 0.55); padding-bottom: 2px; transition: border-color 0.4s var(--ease); }
.rail-contact a:hover { border-color: var(--moon); }

.counter { display: flex; align-items: center; gap: 0.9rem; font-variant-numeric: tabular-nums; }
.counter::before,
.counter::after { content: ''; width: clamp(18px, 5vw, 54px); height: 1px; background: rgba(185, 151, 91, 0.5); }

.rail-link { display: flex; align-items: center; gap: 0.8rem; color: var(--text); }
.rail-link span { border-bottom: 1px solid var(--gold); padding-bottom: 2px; }
.rail-link img { width: 46px; height: 56px; object-fit: cover; filter: saturate(0.7) brightness(0.85); }

/* ---------- carousel controls ---------- */

.arrow {
  position: fixed;
  top: 75%;
  z-index: 3;
  width: 52px;
  height: 52px;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(233, 228, 217, 0.28);
  border-radius: 50%;
  background: rgba(6, 11, 20, 0.28);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition: border-color 0.4s var(--ease), background 0.4s var(--ease);
}

.arrow:hover { border-color: var(--gold); background: rgba(6, 11, 20, 0.55); }
.arrow.prev { left: clamp(0.6rem, 2vw, 1.8rem); }
.arrow.next { right: clamp(0.6rem, 2vw, 1.8rem); }
.arrow svg { width: 15px; height: 15px; }

/* ---------- projected captions ---------- */

#captions { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

.caption {
  position: absolute;
  text-align: left;
  white-space: nowrap;
  opacity: 0;
  text-shadow: 0 2px 5px #03060c, 0 0 12px #03060c;
  transition: opacity 0.5s var(--ease);
}

.caption h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.16rem;
  margin: 0;
  letter-spacing: 0.02em;
}

.caption p { margin: 0.2rem 0 0; font-size: 0.82rem; letter-spacing: 0.12em; color: var(--muted); }

/* ---------- opened painting panel ---------- */

.detail {
  position: fixed;
  z-index: 4;
  right: clamp(1rem, 5vw, 5rem);
  top: 50%;
  translate: 0 -50%;
  width: min(320px, 84vw);
  padding: 1.9rem 1.8rem 1.7rem;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.55s var(--ease), visibility 0.55s;
}

.detail.open { opacity: 1; visibility: visible; }
.detail h2 { font-family: var(--display); font-weight: 400; font-size: 1.75rem; margin: 0 0 0.9rem; }
.detail dl { margin: 0; font-size: 0.92rem; color: var(--muted); letter-spacing: 0.04em; }
.detail dd { margin: 0 0 0.25rem; }
.detail hr { border: 0; border-top: 1px solid rgba(185, 151, 91, 0.4); margin: 1.5rem 0 1.2rem; width: 46px; }
.detail a.enquire { font-size: 0.94rem; border-bottom: 1px solid var(--gold); padding-bottom: 2px; }

.close {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  width: 34px;
  height: 34px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.close:hover { color: var(--text); }

/* While a painting is open, everything else steps back */
.hero, .rail, .arrow { transition: opacity 0.6s var(--ease); }
body.painting-open .hero,
body.painting-open .rail,
body.painting-open .arrow { opacity: 0; pointer-events: none; }

/* ---------- editorial pages (about / contact) ---------- */

.page {
  align-self: center;
  display: grid;
  gap: clamp(2rem, 5vw, 4.5rem);
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: center;
  max-width: 1180px;
  width: 100%;
  margin-inline: auto;
  padding-block: clamp(2rem, 6vh, 5rem);
}

.page h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.3rem, 4.6vw, 4rem);
  line-height: 1.04;
  margin: 0 0 1.4rem;
}

.prose { max-width: 46ch; }
.prose .lede { font-size: 1.06rem; color: var(--text); margin: 0 0 1.6rem; letter-spacing: 0.04em; }
.prose p { line-height: 1.85; color: var(--muted); margin: 0 0 1.1rem; font-size: 0.97rem; }

/* Portrait pair — one main image, one smaller overlapping it */
.portraits { position: relative; }
.portraits img { display: block; width: 100%; border: 1px solid rgba(233, 228, 217, 0.14); }
.portraits .sub {
  position: absolute;
  right: -6%;
  bottom: -12%;
  width: 46%;
  border-color: rgba(185, 151, 91, 0.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* ---------- contact form ---------- */

.form-panel {
  padding: clamp(1.6rem, 3vw, 2.4rem);
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(14px);
  max-width: 420px;
  width: 100%;
}

.field { display: block; margin-bottom: 1.15rem; }
.field span { display: block; font-size: 0.86rem; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.5rem; }

.field input,
.field textarea {
  width: 100%;
  padding: 0.72rem 0.85rem;
  color: var(--text);
  font-family: var(--ui);
  font-size: 0.97rem;
  background: rgba(4, 8, 15, 0.5);
  border: 1px solid rgba(233, 228, 217, 0.18);
  transition: border-color 0.35s var(--ease);
}

.field input:focus,
.field textarea:focus { border-color: var(--gold); outline: none; }
.field textarea { min-height: 128px; resize: vertical; }

.send {
  margin-top: 0.4rem;
  padding: 0.78rem 1.5rem;
  font-family: var(--ui);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--glass-edge);
  cursor: pointer;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}
.send:hover { background: rgba(185, 151, 91, 0.14); border-color: var(--gold); }

.form-note { margin: 1rem 0 0; font-size: 0.86rem; color: var(--muted); min-height: 1.2em; }

/* ---------- loading veil ---------- */

#veil {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: var(--ink);
  transition: opacity 1.1s var(--ease), visibility 1.1s;
}
#veil.gone { opacity: 0; visibility: hidden; }
#veil span { font-family: var(--display); letter-spacing: 0.4em; font-size: 0.8rem; color: var(--muted); }

/* For crawlers and no-JS visitors: real content, visually hidden. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  #stage-fallback { background-position: 73% center; }
  .masthead { align-items: flex-start; flex-direction: column; gap: 0.8rem; }
  .mark { font-size: 0.9rem; letter-spacing: 0.16em; }
  .hero { max-width: 90%; margin-top: 1.2rem; pointer-events: none; }
  .hero h1 { font-size: 2.7rem; }
  .nav { font-size: 0.98rem; gap: 1.15rem; }
  .rail { flex-direction: column; align-items: flex-start; gap: 0.55rem; }
  .tick { width: 7px; height: 18px; }
  .tick[aria-current='true']::before { height: 17px; }
  .rail { font-size: 0.875rem; }
  .rail-contact { flex-wrap: wrap; gap: 0.35rem 1rem; }
  .rail-link img { display: none; }
  .arrow { width: 44px; height: 44px; top: auto; bottom: 5.5rem; translate: 0 0; }

  .detail {
    right: 0; left: 0; top: auto; bottom: 0;
    width: 100%;
    translate: 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    padding: 1.25rem 1.25rem 1.1rem;
    max-height: 34svh;
    overflow: auto;
  }

  .detail h2 { font-size: 1.45rem; margin-bottom: 0.55rem; }
  .detail hr { margin: 0.9rem 0 0.8rem; }

  .portraits .sub { right: 0; bottom: -8%; width: 42%; }
  .page { padding-bottom: 4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
