/* The three.js drawings: the canvas, the handwritten notes pinned to it, the time-of-day switch.
   Loaded after site.css, whose color and font variables it uses.

   Every drawing is a .drawing[data-scene=…] box. Its size comes from where it sits:
     .hero > .drawing   the home picture, beside the headline
     .drawing--how      the road to a title: wide row / two rows / a tall column on a phone
     .drawing--card     a vignette at the top of a card (4:3)
     .drawing--wide     a page-head picture (3:1, 16:10 on a phone)
   The still picture of each drawing is the ::before layer. It shows at full strength from the first paint,
   and stays the picture wherever the live drawing does not run (.is-still: a phone, reduced motion, Save-Data,
   site/assets/js/app.js; .is-flat: no 3D graphics) and while the live drawing waits to load. Once the live
   drawing starts (.is-live) the still fades to a faint placeholder under the pencil, and goes once the drawing
   has drawn itself in (.is-drawn). So nothing looks pale while waiting, and a visitor without script sees the
   whole picture. The "how" stills carry their numbers and titles in each language. The stills are made by
   tools/export_drawings.js. */

.drawing { position: relative; overflow: hidden; container-type: inline-size; }
.drawing__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.drawing::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--still, none) center / cover no-repeat;
  opacity: 1; transition: opacity 1.4s ease 0.3s;
}
/* faint under the pencil while the live drawing draws itself in (it shows through the paper the pencil has
   not reached yet), gone once the drawing has drawn itself in */
.drawing.is-live::before { opacity: 0.4; }
.drawing.is-drawn::before { opacity: 0; }
.drawing:is(.is-flat, .is-still)::before { opacity: 1; transition: none; }
.drawing:is(.is-flat, .is-still) .drawing__canvas { visibility: hidden; }
.drawing:is(.is-flat, .is-still) :is(.drawing__notes, .drawing__moods) { display: none; }

.drawing__notes { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s ease 2.6s; }
.drawing.is-live .drawing__notes { opacity: 1; }
.drawing__moods { position: absolute; right: var(--gutter); bottom: 1.4rem; display: flex; gap: 0.5rem; opacity: 0; transition: opacity 0.6s ease 1s; }
.drawing.is-live .drawing__moods { opacity: 1; }
.drawing__fallback {
  position: absolute; inset: auto var(--gutter) 2rem 5rem; padding: 1rem 1.2rem; font-size: 0.95rem;
  background: var(--paper-deep); border: 1.5px dashed var(--rule); border-radius: var(--wobble);
}

/* ---------- sizes and stills */
.hero > .drawing { align-self: stretch; min-height: clamp(26rem, 74vh, 44rem); margin-left: -4rem; }
.drawing[data-scene="home"] { --still: url("/assets/img/drawings/home-day.webp"); }

.drawing--how { aspect-ratio: 7 / 2; --still: url("/assets/img/drawings/how-wide-en.webp"); }
:lang(es) .drawing--how { --still: url("/assets/img/drawings/how-wide-es.webp"); }
.drawing--card { aspect-ratio: 4 / 3; }
.drawing[data-scene="invest-land"] { --still: url("/assets/img/drawings/invest-land.webp"); }
.drawing[data-scene="invest-apartment"] { --still: url("/assets/img/drawings/invest-apartment.webp"); }
.drawing[data-scene="invest-house"] { --still: url("/assets/img/drawings/invest-house.webp"); }
.drawing--wide { aspect-ratio: 3 / 1; --still: url("/assets/img/drawings/compare-wide.webp"); }

@media (max-width: 64rem) {
  .drawing--how { aspect-ratio: 3 / 2; --still: url("/assets/img/drawings/how-medium-en.webp"); }
  :lang(es) .drawing--how { --still: url("/assets/img/drawings/how-medium-es.webp"); }
}
@media (max-width: 40rem) {
  .drawing--how { aspect-ratio: 1 / 2.9; --still: url("/assets/img/drawings/how-tall-en.webp"); }
  :lang(es) .drawing--how { --still: url("/assets/img/drawings/how-tall-es.webp"); }
  .drawing--wide { aspect-ratio: 16 / 10; --still: url("/assets/img/drawings/compare-narrow.webp"); }
}

/* ---------- the home page's map of the Samaná peninsula (scenes/home-map.js): 16:9, 4:3 on a
   phone; its stills carry the names in each language. The names are notes of their own kind:
   the script puts each above (at-n), below (at-s), beside (at-e, at-w) or on (at-c) its point. */
.drawing--map { aspect-ratio: 16 / 9; --still: url("/assets/img/drawings/home-map-wide-en.webp"); }
:lang(es) .drawing--map { --still: url("/assets/img/drawings/home-map-wide-es.webp"); }
@media (max-width: 40rem) {
  .drawing--map { aspect-ratio: 4 / 3; --still: url("/assets/img/drawings/home-map-phone-en.webp"); }
  :lang(es) .drawing--map { --still: url("/assets/img/drawings/home-map-phone-es.webp"); }
}
.note--map { --gap: 6px; --shift: 0px; }
.note--map.note--place { --gap: 4px; }
.note--map .note__text {
  left: 0; top: 0; bottom: auto; transform-origin: center; white-space: nowrap;
  font-size: clamp(0.78rem, 1.9cqw, 1.45rem); line-height: 1.05; color: var(--ink);
}
.note--map.note--place .note__text { font-size: clamp(0.98rem, 2.5cqw, 1.9rem); font-weight: 700; }
.note--map.note--center .note__text { font-style: italic; color: var(--sea-deep); }
.note--map[data-note="peninsula"] .note__text { color: var(--ink); }
.note--map[data-note="north"] .note__text { font-style: normal; font-weight: 700; color: var(--ink); }
.note--map.note--at-n .note__text { transform: translate(calc(-50% + var(--shift)), calc(-100% - var(--gap))) rotate(-2deg); }
.note--map.note--at-s .note__text { transform: translate(calc(-50% + var(--shift)), var(--gap)) rotate(-2deg); }
.note--map.note--at-e .note__text { transform: translate(calc(var(--gap) + 10px), -50%) rotate(-2deg); }
.note--map.note--at-w .note__text { transform: translate(calc(-100% - var(--gap) - 10px), -50%) rotate(-2deg); }
.note--map.note--at-c .note__text { transform: translate(calc(-50% + var(--shift)), -50%) rotate(-2deg); }

/* a printed page leaves the drawings out: a canvas does not print reliably */
@media print {
  .drawing { display: none !important; }
}

/* ---------- notes
   A note is a point in the picture (placed by the scene's script) with a hand-drawn arrow and a few
   handwritten words. The script picks the side the words go: ne, nw, se or sw of the point.
   --dx/--dy: where the words start, measured from the point; the script reads them too. */
.note {
  --dx: 62px; --dy: 26px; --aw: 56px; --ah: 38px;
  position: absolute; left: 0; top: 0; width: 0; height: 0; color: var(--ink);
  transition: opacity 0.4s ease;
}
.note.is-off { opacity: 0; }
.note__arrow {
  position: absolute; left: 4px; bottom: 4px; width: var(--aw); height: var(--ah); overflow: visible;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.note__text {
  position: absolute; left: var(--dx); bottom: var(--dy); white-space: nowrap;
  font-family: var(--font-hand); font-weight: 600; font-size: 1.55rem; line-height: 1;
  transform: rotate(-4deg); transform-origin: left bottom;
  text-shadow: 0 0 5px var(--paper), 0 0 5px var(--paper), 0 0 2px var(--paper), 0 0 1px var(--paper);
}
.note--nw .note__arrow { left: auto; right: 4px; transform: scaleX(-1); }
.note--nw .note__text { left: auto; right: var(--dx); transform: rotate(3deg); transform-origin: right bottom; }
.note--se .note__arrow { bottom: auto; top: 4px; transform: scaleY(-1); }
.note--se .note__text { bottom: auto; top: var(--dy); transform: rotate(3deg); transform-origin: left top; }
.note--sw .note__arrow { left: auto; right: 4px; bottom: auto; top: 4px; transform: scale(-1, -1); }
.note--sw .note__text { left: auto; right: var(--dx); bottom: auto; top: var(--dy); transform: rotate(-3deg); transform-origin: right top; }

/* A numbered station: a circled number on the path, its title in handwriting beside or below it.
   The script sets --w (how wide the title may run) and the side: note--below, note--right, note--left. */
.note--step { --w: 10rem; }
.note--step .note__num {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%) rotate(-3deg);
  width: 2.3rem; height: 2.3rem; display: grid; place-items: center;
  font-family: var(--font-hand); font-weight: 700; font-size: 1.6rem; line-height: 1;
  background: var(--paper); border: 2px solid currentColor; border-radius: 52% 46% 55% 44% / 47% 55% 45% 53%;
}
.note--step .note__text {
  bottom: auto; width: var(--w); white-space: normal; font-size: 1.12rem; line-height: 1.12;
  transform: rotate(-1.5deg);
}
.note--below .note__text { left: calc(var(--w) / -2); top: 1.45rem; text-align: center; transform-origin: center top; }
.note--right .note__text { left: 1.55rem; top: -0.75em; text-align: left; transform-origin: left center; }
.note--left .note__text { left: auto; right: 1.55rem; top: -0.75em; text-align: right; transform-origin: right center; }

/* A word written on a thing in the picture (the "3%" on the tax tag): centered on its point. */
.note--tag .note__text {
  left: 0; top: 0; bottom: auto; transform: translate(-50%, -50%) rotate(-12deg);
  font-size: 1.25rem; font-weight: 700; text-shadow: none;
}

@media (max-width: 62rem) {
  /* a phone's picture is a little taller than wide: the story is told from the sea up the hill */
  .hero > .drawing { margin-left: 0; min-height: 0; height: min(120vw, 36rem); }
  .note__text { font-size: 1.3rem; }
}
/* a small picture gets smaller notes */
@container (max-width: 36rem) {
  .note { --dx: 34px; --dy: 16px; --aw: 32px; --ah: 24px; }
  .note__text { font-size: 1.08rem; }
  /* on the home picture the notes wrap and scale with the picture's width, so all three fit even
     with a large default text size; the script then picks a side where each fits whole */
  .drawing[data-scene="home"] .note__text {
    font-size: min(1.08rem, 5.2cqw); white-space: normal; width: max-content; max-width: 34cqw; line-height: 1.05;
  }
  .drawing[data-scene="home"] :is(.note--nw, .note--sw) .note__text { text-align: right; }
  .note--step .note__text { font-size: 1.02rem; }
  .note--step .note__num { width: 2rem; height: 2rem; font-size: 1.35rem; }
  .note--tag .note__text { font-size: 1.05rem; }
}
/* on a phone the picture is short, so the time-of-day switch moves up into the sky and the sea
   and the boats at the bottom stay clear */
@media (max-width: 62rem) {
  @container (max-width: 36rem) {
    .drawing__moods { top: 0.75rem; bottom: auto; left: var(--gutter); right: auto; }
    .drawing__moods .chip { font-size: 0.8rem; padding: 0.2rem 0.7rem; }
  }
}

/* ---------- the map of Las Terrenas (site/assets/js/map/map.js, baked by tools/build_map.js)
   A picture of the area with numbered pins; without JavaScript the picture alone shows. */
.pmap { margin-block: 1.2rem 0.4rem; }
.pmap__frame { position: relative; }
.pmap__img, .opp-map__still { display: block; width: 100%; height: auto; border-radius: 1.2rem 0.4rem 1.4rem 0.5rem; }
.pmap__pins { position: absolute; inset: 0; }
.pmap__pin {
  position: absolute; width: 2.2rem; height: 2.2rem; margin: 0; padding: 0;
  transform: translate(-50%, -50%); display: grid; place-items: center;
  font-family: var(--font-hand); font-weight: 700; font-size: 1.35rem; line-height: 1; color: var(--ink);
  background: var(--gold); border: 2px solid var(--ink); border-radius: 52% 46% 55% 44% / 47% 55% 45% 53%;
  box-shadow: 2px 3px 0 color-mix(in srgb, var(--ink) 35%, transparent); cursor: pointer;
  transition: transform 0.15s ease;
}
/* the place itself (a dot) and, when the number had to move aside, a pencil line to it */
.pmap__leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pmap__leader { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.pmap__dot { fill: var(--gold); stroke: var(--ink); stroke-width: 1.6; }
.pmap__dot--apartment { fill: var(--sea); }
.pmap__dot--house { fill: var(--coral); }
.pmap__pin--apartment { background: var(--sea); color: var(--paper); }
.pmap__pin--house { background: var(--coral); color: var(--paper); }
.pmap__pin--off { border-style: dashed; }
.pmap__pin:hover { transform: translate(-50%, -50%) scale(1.1); }
.pmap__pin:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.pmap__pin[hidden] { display: none; }
/* a touch target of at least 44 px round the drawn 2.2rem pin, without changing how it looks */
.pmap__pin::after { content: ""; position: absolute; inset: -0.35rem; border-radius: 50%; }
.pmap__legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.1rem; margin-top: 0.7rem; font-size: 0.95rem; color: var(--ink-soft); }
.pmap__legend-head { font-weight: 650; color: var(--ink); }
.pmap__key::before {
  content: ""; display: inline-block; width: 0.85rem; height: 0.85rem; margin-right: 0.4rem; vertical-align: -0.1rem;
  border: 1.5px solid var(--ink); border-radius: 50%; background: var(--gold);
}
.pmap__key--apartment::before { background: var(--sea); }
.pmap__key--house::before { background: var(--coral); }
.pmap__key--built::before { background: #f2dcbf; border-radius: 0.2rem; border-color: #c08a5a; }
.pmap__credit { margin-top: 0.35rem; font-size: 0.82rem; color: var(--ink-soft); }
.pmap .visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@container (max-width: 36rem) {
  .pmap__pin { width: 1.85rem; height: 1.85rem; font-size: 1.12rem; }
}
@media (max-width: 40rem) {
  .pmap__pin { width: 1.85rem; height: 1.85rem; font-size: 1.12rem; }
}
@media (prefers-reduced-motion: reduce) {
  .pmap__pin { transition: none; }
  .pmap__pin:hover { transform: translate(-50%, -50%); }
}
@media print {
  .pmap__pins, .pmap__leaders, .pmap__legend { display: none; }
}

/* the time-of-day buttons keep their small look but get a touch area of at least 44 x 44 px:
   an invisible layer centred on each button, never narrower or shorter than the button itself */
.drawing__moods .chip { position: relative; }
.drawing__moods .chip::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(100%, 44px); height: max(100%, 44px);
}

/* the time-of-day chips' visible label (clarity audit 2026-11-17: WCAG 3.3.2), legible over the drawing */
.drawing__moods-label {
  align-self: center; padding: 0.2rem 0.55rem; font-size: 0.85rem; font-weight: 600; color: var(--ink);
  background: color-mix(in srgb, var(--paper) 88%, transparent); border-radius: var(--wobble);
}
