/* Serenità Resorts. Tokens come from the client's own photos: plaster, limestone, teak, canopy. */
:root {
  --paper: #f2ece5;
  --paper-2: #e6ded2;
  --ink: #24211c;
  --forest: #18201b;
  --teak: #8a6a48;
  --ink-soft: color-mix(in oklab, var(--ink) 66%, var(--paper));
  --line: color-mix(in oklab, var(--ink) 16%, transparent);
  --line-light: rgb(255 255 255 / 0.28);

  --f-display: "Newsreader", "Times New Roman", serif;
  --f-body: "Instrument Sans", system-ui, sans-serif;
  --f-hand: "La Belle Aurore", cursive;

  /* Fluid scale: min at 375px, max at 1440px. */
  --t-hero: clamp(3.25rem, 1.6rem + 6.6vw, 7.5rem);
  --t-hour: clamp(6rem, 2.4rem + 12.6vw, 14.5rem);
  --t-h2: clamp(2.5rem, 1.5rem + 4vw, 5.25rem);
  --t-lede: clamp(1.75rem, 1.15rem + 2.4vw, 3.4rem);
  --t-h3: clamp(1.5rem, 1.25rem + 0.9vw, 2.125rem);
  --t-hand: clamp(1.6rem, 1.15rem + 1.9vw, 2.75rem);
  --t-body: clamp(1rem, 0.97rem + 0.12vw, 1.0625rem);
  --t-label: 0.6875rem;

  --gutter: clamp(16px, 2vw, 32px);
  --section: clamp(104px, 14vw, 200px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-inout: cubic-bezier(0.76, 0, 0.24, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--forest); }
body {
  margin: 0; background: var(--forest); color: var(--ink);
  font: 400 var(--t-body)/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, video { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p, figure { margin: 0; }
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

.skip { position: absolute; left: var(--gutter); top: -60px; z-index: 50; background: var(--paper); padding: 10px 14px; }
.skip:focus { top: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Type ─────────────────────────────────────────────────────────────────── */
.display {
  font-family: var(--f-display); font-weight: 200; font-variation-settings: "opsz" 72;
  line-height: 0.98; letter-spacing: -0.02em; text-wrap: balance;
}
.display em { font-style: italic; }
.h2 { font-size: var(--t-h2); }
.h3 { font-family: var(--f-display); font-weight: 300; font-size: var(--t-h3); line-height: 1.15; letter-spacing: -0.01em; }
.lede { font-size: var(--t-lede); line-height: 1.1; letter-spacing: -0.015em; }
.label { font: 500 var(--t-label)/1.2 var(--f-body); letter-spacing: 0.22em; text-transform: uppercase; }
.center { text-align: center; margin-inline: auto; }
p { text-wrap: pretty; }

.wrap { padding-inline: var(--gutter); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); }

/* ── Header: difference blend keeps it legible over photographs and paper alike. ── */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 22px var(--gutter); color: #fff; mix-blend-mode: difference;
}
.site-header a { text-decoration: none; }
.nav-links { display: flex; gap: 28px; }
.wordmark {
  font-family: var(--f-display); font-weight: 300; font-size: 1.05rem;
  letter-spacing: 0.34em; text-transform: uppercase; padding-left: 0.34em;
}
.nav-cta { justify-self: end; }
.nav-links a, .nav-cta { position: relative; padding-block: 6px; }
.nav-links a::after, .nav-cta::after, .link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.6s var(--ease-out);
}
.nav-links a:hover::after, .nav-cta:hover::after, .link:hover::after,
.nav-links a:focus-visible::after, .nav-cta:focus-visible::after { transform: scaleX(1); transform-origin: left; }

/* Side rail, after Tandjung Sari: the chapter you are in, set vertically on the right edge. */
.rail {
  position: fixed; right: var(--gutter); top: 50%; z-index: 20; color: #fff; mix-blend-mode: difference;
  writing-mode: vertical-rl; transform: translateY(-50%); display: flex; gap: 22px; align-items: center;
  font-size: 0.625rem; pointer-events: none;
}
.rail-count { opacity: 0.6; }

/* ── The stage ──────────────────────────────────────────────────────────────── */
.stage { position: fixed; inset: 0; height: 100lvh; z-index: 0; overflow: hidden; background: var(--paper-2); }
.plate { position: absolute; inset: 0; opacity: 0; will-change: opacity; }
.plate:first-child { opacity: 1; }
.plate img { width: 100%; height: 100%; object-fit: cover; transform-origin: 50% 50%; will-change: transform; }
/* Paper veil: warm plaster laid over the photograph, so text-heavy chapters read like paper
   while the place still shows through. Multiply keeps the shadows, lifts the rest. */
.veil { position: absolute; inset: 0; z-index: 5; background: var(--paper); opacity: 0.5; }
.shade {
  position: absolute; inset: 0; opacity: 0; z-index: 6;
  background:
    linear-gradient(180deg, rgb(16 20 17 / 0.55) 0%, rgb(16 20 17 / 0) 26%, rgb(16 20 17 / 0) 48%, rgb(16 20 17 / 0.85) 100%),
    rgb(16 20 17 / 0.18);
}

main, .footer { position: relative; z-index: 1; }

/* ── 01 Hero ─────────────────────────────────────────────────────────────── */
/* The hero runs 18% past the fold and its film fades out over that overhang, so it melts into
   the first plate instead of ending on a hard edge. */
.hero { position: relative; height: 118svh; min-height: 640px; color: #fff; }
.hero-media {
  position: absolute; inset: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 84%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 84%, transparent 100%);
}
.hero-video { width: 100%; height: 100%; object-fit: cover; }
.hero-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(16 20 17 / 0.42) 0%, rgb(16 20 17 / 0) 22%, rgb(16 20 17 / 0.05) 55%, rgb(16 20 17 / 0.62) 100%);
}
.hero-inner {
  position: relative; z-index: 1; height: 100svh; min-height: 540px;
  display: grid; align-content: end; gap: 22px; padding-bottom: clamp(24px, 4vw, 48px);
}
.hero-title { font-size: var(--t-hero); max-width: 11ch; }
.hero-title em { display: block; padding-left: 1.1em; }
.hero-foot {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--line-light); padding-top: 16px; margin-top: clamp(8px, 2vw, 24px);
}
.video-toggle {
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  background: none; border: 0; padding: 12px 0 12px 12px; cursor: pointer;
}

/* ── 02 Letter ─────────────────────────────────────────────────────────────── */
.letter { min-height: 110svh; display: grid; place-items: center; padding: var(--section) var(--gutter); color: var(--ink); }
.letter-sheet { width: min(100%, 860px); transform: rotate(-2.5deg); }
.hand { font-family: var(--f-hand); font-size: var(--t-hand); line-height: 1.55; color: #1d1a16; }
.hand-line { display: block; width: fit-content; }
.hand-line:nth-child(even) { margin-left: 0.6em; }
.hand-line.gap { margin-top: 0.7em; }
.hand-sign { margin-top: 0.6em; margin-left: auto; width: fit-content; font-size: calc(var(--t-hand) * 1.5); }

/* ── 03 Place ──────────────────────────────────────────────────────────────── */
.place { padding-block: var(--section); color: var(--ink); }
.place .lede { max-width: 22ch; margin-top: 28px; }
.pillars { margin-top: clamp(72px, 10vw, 140px); row-gap: 48px; }
.pillar { grid-column: span 4; border-top: 1px solid var(--line); padding-top: 22px; }
.pillar p:last-child { color: var(--ink-soft); margin-top: 12px; max-width: 34ch; }
.pillar-num { font-family: var(--f-display); font-style: italic; font-weight: 200; font-size: 1.25rem; color: var(--teak); margin-bottom: 18px; }

/* ── 04 A day ──────────────────────────────────────────────────────────────── */
.day-intro { min-height: 90svh; display: grid; align-content: center; color: #fff; padding-block: var(--section); }
.day-intro .h2 { margin-top: 20px; max-width: 12ch; }
.hour {
  min-height: 135svh; color: #fff; display: grid; align-content: end;
  padding-block: var(--section) clamp(56px, 9vw, 120px);
}
.hour-num { font-size: var(--t-hour); line-height: 0.82; letter-spacing: -0.045em; font-variant-numeric: lining-nums; }
.hour-copy {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gutter);
  border-top: 1px solid var(--line-light); padding-top: 22px; margin-top: clamp(20px, 3vw, 36px);
}
.hour-copy p { max-width: 38ch; opacity: 0.86; }

/* ── 05 Residences ─────────────────────────────────────────────────────────── */
.residences { padding-block: var(--section); color: var(--ink); }
.res-head { display: grid; gap: 20px; margin-bottom: clamp(48px, 7vw, 96px); }
.cards { row-gap: 64px; }
.card { grid-column: span 4; display: grid; align-content: start; }
.card:nth-child(2) { margin-top: clamp(0px, 8vw, 120px); }
.card-media { overflow: hidden; aspect-ratio: 4 / 5; background: var(--paper-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.4s var(--ease-out); }
.card:hover .card-media img { transform: scale(1.035); }
.card-index { color: var(--teak); margin-top: 20px; }
.card .h3 { margin-top: 10px; }
.card-meta { color: var(--ink-soft); margin-top: 8px; max-width: 36ch; }
.link { position: relative; justify-self: start; margin-top: 16px; padding-block: 6px; text-decoration: none; font-size: 0.9375rem; }
.link::after { transform: scaleX(1); transform-origin: left; opacity: 0.4; }
.link:hover::after { opacity: 1; }

/* ── 06 Interlude ──────────────────────────────────────────────────────────── */
.interlude { min-height: 120svh; display: grid; place-items: center; color: #fff; text-align: center; padding-block: var(--section); }
.quote { font-size: var(--t-h2); max-width: 15ch; }
.quote em { display: block; }

/* ── 07 Table ──────────────────────────────────────────────────────────────── */
.table { min-height: 120svh; display: grid; align-content: end; color: #fff; padding-block: var(--section); }
.table-copy { display: grid; gap: 22px; max-width: 760px; }
.table .h2 { max-width: 14ch; }
.body-lg { font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem); max-width: 44ch; opacity: 0.88; }

/* ── 08 Stay ───────────────────────────────────────────────────────────────── */
.stay { min-height: 100svh; display: grid; align-content: center; color: #fff; padding-block: var(--section); }
.stay-head { grid-column: 1 / span 5; display: grid; align-content: start; gap: 22px; }
.stay-head .h2 { max-width: 10ch; }
.stay-note { opacity: 0.8; max-width: 32ch; }
.enquire {
  grid-column: 7 / span 6; display: grid; grid-template-columns: 1fr 1fr; gap: 28px var(--gutter);
  align-content: start;
}
.field { display: grid; gap: 6px; }
.field.wide, .form-foot.wide { grid-column: 1 / -1; }
.field label { font: 500 var(--t-label)/1.2 var(--f-body); letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.75; }
.field input, .field select, .field textarea {
  font: inherit; color: #fff; background: transparent; border: 0; border-bottom: 1px solid var(--line-light);
  border-radius: 0; padding: 10px 0; min-height: 48px; color-scheme: dark; width: 100%;
  transition: border-color 0.4s var(--ease-out);
}
.field select option { color: var(--ink); background: var(--paper); }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-bottom-color: #fff; }
.form-foot { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  font: 500 0.8125rem/1 var(--f-body); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink); background: var(--paper); border: 0; padding: 18px 28px; min-height: 52px; cursor: pointer;
  transition: background 0.4s var(--ease-out), color 0.4s var(--ease-out);
}
.btn:hover, .btn:focus-visible { background: #fff; }
.form-status { font-size: 0.9375rem; opacity: 0.9; max-width: 40ch; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer { color: var(--paper); padding-block: var(--section) var(--gutter); }
/* fitOne() in main.js sizes this exactly to the gutters; 24vw is the no-JS fallback. */
.footer .big { font-size: 24vw; line-height: 0.85; letter-spacing: -0.035em; white-space: nowrap; margin-bottom: clamp(48px, 7vw, 104px); }
.footer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gutter); border-top: 1px solid var(--line-light); padding-top: 24px; }
.footer-grid p:last-child { margin-top: 10px; }
.footer-grid a { text-decoration: none; }
.footer-grid a:hover { text-decoration: underline; text-underline-offset: 4px; }
.dim { opacity: 0.6; }
.footer-bottom { display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-top: clamp(56px, 8vw, 96px); padding-top: 18px; border-top: 1px solid var(--line-light); opacity: 0.7; font-size: 0.625rem; }

/* ── Phone composition ────────────────────────────────────────────────────── */
@media (max-width: 899px) {
  .nav-links, .rail { display: none; }
  .site-header { grid-template-columns: 1fr auto; }
  .wordmark { justify-self: start; }
  .pillar { grid-column: 1 / -1; }
  .card { grid-column: 1 / -1; }
  .card:nth-child(2) { margin-top: 0; }
  .stay-head, .enquire { grid-column: 1 / -1; }
  .enquire { margin-top: 48px; }
  .hour-copy { grid-template-columns: 1fr; gap: 12px; }
  .footer-grid { grid-template-columns: 1fr 1fr; row-gap: 32px; }
}
@media (max-width: 559px) {
  .hero-title em { padding-left: 0.6em; }
  .letter-sheet { transform: rotate(-1.5deg); }
  .hand-line:nth-child(even) { margin-left: 0; }
  .enquire { grid-template-columns: 1fr; }
  .hour { min-height: 120svh; }
}

/* ── Motion states. JS adds .js; everything is visible without it. ────────── */
.js [data-reveal] { opacity: 0; }
.js [data-write] .hand-line { clip-path: inset(-20% 100% -20% 0); }

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1; }
  .js [data-write] .hand-line { clip-path: none; }
  .card-media img, .nav-links a::after, .nav-cta::after, .link::after { transition: none; }
}
