/* Palette taken from the photos: cloudy valley sky, wrought iron, the hills.
   Each apartment's own colour comes from js/data.js (--acc / --on-acc). */
:root {
  --bg: #e7e9e3;     /* nebbia: the sky over the valley */
  --ink: #1d221e;    /* ferro: balcony railings, bed frames */
  --mute: #5f6a5c;   /* collina */
  --line: #c6ccc2;
  --closed: #d6dad2;
  --acc: var(--ink); --on-acc: var(--bg);
  --narrow: "wdth" 62;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d221e; --ink: #e7e9e3; --mute: #9aa395; --line: #353c36; --closed: #2a302b;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d221e; --ink: #e7e9e3; --mute: #9aa395; --line: #353c36; --closed: #2a302b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--ink); font: 400 16px/1.55 Archivo, system-ui, sans-serif; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }

/* ---------- layout: photo left, content right ---------- */
.layout { display: grid; grid-template-columns: 11fr 9fr; }
.stage { position: sticky; top: 0; height: 100vh; overflow: hidden; background: var(--ink); }
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .8s; }
.stage img.on { opacity: 1; }
.col { min-width: 0; --pad: clamp(24px, 5vw, 80px); padding: 0 var(--pad); }

.bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  margin: 0 calc(-1 * var(--pad)); padding: 20px var(--pad); background: var(--bg); } /* full width, so nothing shows beside it */
.mark { font: 700 22px/1 Archivo; font-variation-settings: var(--narrow); text-decoration: none; }
.tools { display: flex; align-items: center; gap: 4px; }
.tools button { background: none; border: 0; padding: 6px 8px; cursor: pointer; color: var(--mute); font-size: 14px; }
.tools button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.tools .icon { font-size: 18px; }

/* ---------- hero: word between sky and hills ----------
   .view is the photo's frame (whole screen on phones, left column on desktop).
   .scene keeps the photo's proportions and covers .view, so the title
   (positioned in % of the scene) always meets the skyline at the same spot. */
.hero { position: relative; height: 100svh; overflow: clip; background: #1d221e; color: #fff; }
.view { position: absolute; inset: 0; overflow: hidden; container-type: size; }
.scene { position: absolute; left: 50%; transform: translateX(-50%);
  --ratio: 0.6667;           /* vista.png width / height (1024 x 1536) */
  --skyline: 0.405;          /* where the hills start, as a fraction of photo height */
  --sw: max(100cqw, 100cqh * var(--ratio));
  --sh: calc(var(--sw) / var(--ratio));
  width: var(--sw); height: var(--sh);
  --start: clamp(100cqh - var(--sh), 66cqh - var(--skyline) * var(--sh), 0px); /* skyline at 2/3 of the frame */
  --end: max(calc(100cqh - .9 * var(--sh)), calc(100cqh - var(--sh)));           /* frame bottom at 90% of the photo: the railing */
  top: calc(var(--start) + (var(--end) - var(--start)) * var(--pan, 0));
  /* 250-byte blurry preview, shown instantly while the two layers download */
  background: url("data:image/webp;base64,UklGRrQAAABXRUJQVlA4IKgAAABwBACdASoQABgAPtFWpEwoJKOiMAgBABoJbACdIExgsw43KbIlRHVTV3qmAADxyQbbs5iWLELxkWRs3hQkZZgLDzhQflD+K8H3So1jy5W0tkN2fxbLv7ERnrJM/X3kL274RCbEsq0PnhJo/jmTdvXl060T5UgdWJqDq7fIEX3vTs8tjItLonj2yWsNpi56f/EB419E0KqreRfgA1EEvPfYYwgs26d7wAA=") center / 100% 100%; }
.scene img { position: absolute; left: 0; width: 100%; }
/* the photo is split in two files: hero-sky.webp = top 50%, hero-hills.webp = from 37.5% down (sky transparent) */
.sky { top: 0; height: 50%; transform: translateY(calc(var(--sink, 0) * 6%)); }
.hills { top: 37.5%; height: 62.5%; }
/* darkens only the sky (the hills layer sits above it) so the white word reads on bright clouds */
.shade { position: absolute; inset: 0; background: linear-gradient(rgb(20 26 22 / .42), rgb(20 26 22 / .22) 30%, rgb(20 26 22 / .08) 40%, transparent 45%); }
.title { position: absolute; left: 0; right: 0; bottom: 57.5%; text-align: center; color: #fff;
  font: 800 26cqw/.78 Archivo; font-variation-settings: "wdth" 62; letter-spacing: -.015em;
  text-shadow: 0 0 .25em rgb(20 26 22 / .25); }
.title > span, .title .sink { display: block; }
.rise { animation: rise 2.6s cubic-bezier(.16, .8, .2, 1) .3s both; }
.hero:not(.ready) .rise { animation-play-state: paused; }  /* wait until the hills are there to hide behind */
.sink { transform: translateY(calc(var(--sink, 0) * 85%)); }
@keyframes rise { from { transform: translateY(105%); } }

.hero-tools { position: absolute; top: 16px; right: clamp(16px, 4vw, 56px); z-index: 3; }
.hero-tools button, .hero-tools button[aria-pressed="true"] { color: #fff; }
.hero-tools button { opacity: .75; } .hero-tools button[aria-pressed="true"] { opacity: 1; }
.hero-foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: flex-end;
  align-items: flex-end; gap: 24px; flex-wrap: wrap; padding: clamp(16px, 4vw, 56px); padding-top: 120px;
  background: linear-gradient(transparent, rgb(0 0 0 / .45)); }
.picker { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(200px, 260px)); gap: 8px; }
.picker a { display: block; text-decoration: none; background: var(--acc); color: var(--on-acc); padding: clamp(12px, 3vw, 18px) clamp(12px, 3vw, 20px); }
.picker b { display: block; white-space: nowrap; font: 700 clamp(22px, 6.5vw, 34px)/1 Archivo; font-variation-settings: var(--narrow); }
.picker span { font-size: 14px; opacity: .85; }
.picker a:hover { filter: brightness(1.08); }

/* ---------- apartment ---------- */
.apt { padding: 14vh 0 6vh; }
.name { font: 800 clamp(64px, 8.5vw, 150px)/.82 Archivo; font-variation-settings: var(--narrow); color: var(--acc); letter-spacing: -.01em; }
.price { margin: 18px 0 36px; font-size: 18px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--ink); }
.facts div { padding: 14px 0 0; }
.facts dt { font: 600 44px/1 Archivo; font-variation-settings: var(--narrow); }
.facts dd { color: var(--mute); font-size: 14px; }
.rooms { width: 100%; border-collapse: collapse; margin: 36px 0 0; font-size: 15px; }
.rooms td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rooms td + td { text-align: right; color: var(--mute); }
.sub { font-size: 15px; font-weight: 600; margin: 44px 0 12px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 4px; }
.thumbs button { padding: 0; border: 0; background: none; cursor: pointer; aspect-ratio: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .7; transition: opacity .2s; }
.thumbs button:hover img, .thumbs [aria-current="true"] img { opacity: 1; }
.thumbs [aria-current="true"] { outline: 2px solid var(--acc); outline-offset: 1px; }

/* ---------- calendar ---------- */
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-nav button { background: none; border: 1px solid var(--line); width: 36px; height: 36px; cursor: pointer; }
.cal-nav button:disabled { opacity: .3; cursor: default; }
.months { display: grid; grid-template-columns: 1fr 1fr; }
.month { padding: 0 28px; }
.month:first-child { padding-left: 0; }
.month:last-child { padding-right: 0; }
.month + .month { border-left: 1px solid var(--line); }   /* clean divider between the two months */
.month h4 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.month h4 span:first-child { text-transform: capitalize; }
.m-price { font-weight: 400; font-size: 13px; color: var(--mute); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 14px; text-align: center; }
.days abbr { color: var(--mute); font-size: 12px; text-decoration: none; padding-bottom: 4px; }
.days button { aspect-ratio: 1; border: 0; background: none; cursor: pointer; font-variant-numeric: tabular-nums; }
.days button:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--acc); }
.days button.closed { background: repeating-linear-gradient(135deg, var(--closed) 0 4px, transparent 4px 7px); color: var(--mute); cursor: not-allowed; }
.days button.past { color: var(--line); cursor: default; }
.days button.in { background: color-mix(in srgb, var(--acc) 22%, transparent); }
.days button.end { background: var(--acc); color: var(--on-acc); font-weight: 600; }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); min-height: 64px; }
.cal-foot p { color: var(--mute); font-size: 15px; }
.cal-foot p b { color: var(--ink); font-weight: 600; }
.go { background: var(--acc); color: var(--on-acc); border: 0; padding: 13px 22px; font-weight: 600; text-decoration: none; cursor: pointer; }
.note { font-size: 14px; color: var(--mute); margin-top: 10px; }

/* key rules right under each calendar, so they're read before requesting */
.before { margin: 0 0 20px; padding-left: 14px; border-left: 2px solid var(--acc); font-size: 15px; max-width: 60ch; }
.before a { white-space: nowrap; text-underline-offset: 3px; }

/* ---------- good to know + amenities ---------- */
.info { padding: 14vh 0 4vh; border-top: 1px solid var(--line); margin-top: 8vh; }
.info h2 { font: 800 clamp(48px, 6vw, 96px)/.9 Archivo; font-variation-settings: var(--narrow); margin-bottom: 28px; }
.info-list div { display: grid; grid-template-columns: minmax(120px, 13rem) 1fr; gap: 4px 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.info-list dt { font-weight: 600; }
.info-list dd { max-width: 60ch; }
.info-list a { text-underline-offset: 3px; }
.info .sub { font: 700 clamp(28px, 2.6vw, 38px)/1 Archivo; font-variation-settings: var(--narrow); margin: 64px 0 20px; }
.amen { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
.amen h4 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.amen ul { list-style: none; padding: 0; color: var(--mute); font-size: 15px; line-height: 1.9; }

/* ---------- contact ---------- */
.contact { padding: 14vh 0 32px; border-top: 1px solid var(--line); margin-top: 8vh; }
.contact h2 { font: 800 clamp(48px, 6vw, 96px)/.9 Archivo; font-variation-settings: var(--narrow); margin-bottom: 28px; }
.contact ul { list-style: none; padding: 0; }
.contact li a { display: inline-block; font-size: clamp(20px, 2vw, 28px); padding: 6px 0; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.cin { margin-top: 12vh; font-size: 13px; color: var(--mute); }

/* ---------- phone gallery (hidden on desktop, where the stage + thumbnails do the job) ---------- */
.carousel { display: none; position: relative; margin: 0 -16px 28px; }
.slides { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
  padding: 0 16px; scrollbar-width: none; overscroll-behavior-x: contain; }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 86%; width: 86%; min-width: 0; aspect-ratio: 4 / 5; object-fit: cover; scroll-snap-align: start; background: var(--closed); }
/* arrows only where there's a mouse; touch screens swipe */
.carousel .nav { display: none; position: absolute; top: 50%; translate: 0 -70%; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgb(255 255 255 / .9); color: #1d221e; font-size: 26px; line-height: 1; cursor: pointer; box-shadow: 0 2px 10px rgb(0 0 0 / .25); }
.carousel .prev { left: 24px; } .carousel .next { right: 24px; }
.carousel .nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .carousel .nav { display: grid; place-items: center; } }
.carousel .count { position: absolute; left: 24px; bottom: 10px; padding: 2px 10px; border-radius: 99px;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; pointer-events: none; }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stage { display: none; }
  .col { --pad: 16px; }
  .carousel { display: block; }
  .thumbs, .photos-h { display: none; }
  .picker { grid-template-columns: 1fr 1fr; width: 100%; }
  .apt { padding-top: 0; scroll-margin-top: 64px; }  /* photos start right under the sticky bar */
  .apt + .apt { margin-top: 6vh; }
  .facts dt { font-size: 34px; }
  .months { grid-template-columns: 1fr; }
  .info-list div { grid-template-columns: 1fr; }
  .month, .month:first-child, .month:last-child { padding: 0; }
  .month + .month { border-left: 0; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 20px; }
}
/* tall frames: break the word in two lines, Bella / vista */
@container (max-aspect-ratio: 5 / 4) {
  .title { font-size: min(37cqw, var(--sh) * .2); bottom: 58.5%; }
  .title .sink span { display: block; }
}
/* landscape screens: the photo is wider than tall there, so instead of cropping it the frame stays put
   while scrolling pans it from the sky down to the railing (--pan 0 → 1, set in app.js) */
@media (min-aspect-ratio: 1 / 1) and (min-width: 901px) {
  .hero { height: 220svh; }
  .view { position: sticky; inset: auto; top: 0; height: 100svh; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise { animation: none; }
  .sink, .sky { transform: none; }
  .hero { height: 100svh !important; }
  .stage img, .thumbs img { transition: none; }
}
