@layer components {
  /* ---------- Buttons ---------- */
  .btn {
    --btn-bg: var(--color-primary);
    --btn-fg: #fff;

    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-s) var(--space-l);
    border: 2px solid var(--btn-bg);
    border-radius: 999px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: translate 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out),
      background-color 0.2s;

    &:hover {
      translate: 0 -2px;
      box-shadow: var(--shadow-m);
    }

    /* Variants only swap the custom properties; the rules above stay the same */
    &.btn-accent {
      --btn-bg: var(--color-accent);
    }

    &.btn-ghost {
      --btn-bg: transparent;
      --btn-fg: currentColor;
      border-color: currentColor;
    }

    /* Messenger brand look: Meta's blue → purple → pink gradient + the logo,
       so people recognise "this opens Messenger" before reading the text.
       A gradient can't be a border-color, so the border goes transparent
       and the gradient is painted as background-image instead. */
    &.btn-messenger {
      --btn-bg: #0a7cff;
      --btn-fg: #fff;
      border-color: transparent;
      background-image: linear-gradient(to top right, #0099ff 0%, #a033ff 55%, #ff5280 85%, #ff7061 100%);
      /* Size the gradient to the OUTER edge. By default it's sized to the
         padding box and repeats under the transparent border as a thin seam. */
      background-origin: border-box;

      &:hover {
        box-shadow: 0 8px 24px rgb(160 51 255 / 0.35);
      }
    }

    /* Same idea for the other socials. Shades are each brand's own button
       colors that keep white text at 4.5:1+ (Facebook's older #1877f2 and
       Airbnb's #ff385c both fall short of that). */
    &.btn-facebook {
      --btn-bg: #0866ff;

      &:hover {
        box-shadow: 0 8px 24px rgb(8 102 255 / 0.35);
      }
    }

    /* TikTok's cue is the cyan/red offset "glitch" behind the black note */
    &.btn-tiktok {
      --btn-bg: #010101;

      & .icon {
        filter: drop-shadow(-1.5px -1px 0 #25f4ee) drop-shadow(1.5px 1px 0 #fe2c55);
      }

      &:hover {
        box-shadow: -4px 6px 20px rgb(37 244 238 / 0.3), 4px 8px 20px rgb(254 44 85 / 0.3);
      }
    }

    &.btn-airbnb {
      --btn-bg: #e61e4d;
      border-color: transparent;
      background-image: linear-gradient(to right, #e61e4d 0%, #e31c5f 50%, #d70466 100%);
      background-origin: border-box;

      &:hover {
        box-shadow: 0 8px 24px rgb(230 30 77 / 0.35);
      }
    }

    & .icon {
      width: 1.25em;
      height: 1.25em;
      flex-shrink: 0;
      fill: currentColor;
    }

    /* Compact size for the header. It lives here, not in layout.css,
       because the "components" layer beats "layout": a .header-cta rule in
       layout.css would lose to .btn's padding no matter what. */
    &.header-cta {
      padding: var(--space-2xs) var(--space-m);
      font-size: var(--step--1);
    }
  }

  /* ---------- Home hero ---------- */
  .hero {
    position: relative;
    display: grid;
    place-items: end start;
    min-height: calc(100svh - var(--header-h));
    padding-block: var(--space-2xl);
    overflow: clip;
    color: var(--color-on-image);
    isolation: isolate;

    & .hero-media {
      position: absolute;
      inset: 0;
      z-index: -2;

      & img {
        width: 100%;
        height: 100%;
        /* cover = fill the box and crop the overflow, never distort.
           object-position picks which part of the photo survives the crop:
           here, slightly below center so the waterfall and pool stay in view. */
        object-fit: cover;
        object-position: 50% 65%;
      }
    }

    /* Gradient scrim keeps the text readable over any photo */
    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background: linear-gradient(
        to top,
        rgb(0 0 0 / 0.7) 0%,
        rgb(0 0 0 / 0.25) 45%,
        rgb(0 0 0 / 0.1) 100%
      );
    }

    & .hero-content {
      display: grid;
      gap: var(--space-m);
      justify-items: start;
    }

    & .eyebrow {
      color: inherit;
      letter-spacing: 0.14em;
    }

    & h1 {
      max-width: 14ch;
    }

    & p {
      font-size: var(--step-1);
      max-width: 40ch;
    }

    & .btn-ghost {
      --btn-fg: #fff;
    }

    & .hero-actions {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-s);
    }
  }

  /* ---------- Mt. Makiling showcase ---------- */
  .view-showcase {
    position: relative;
    display: grid;
    align-items: end;
    min-height: 90svh;
    padding-block: var(--space-xl);
    overflow: clip;
    isolation: isolate;
    color: var(--color-on-image);

    & img {
      position: absolute;
      inset: 0;
      z-index: -2;
      width: 100%;
      height: 100%;
      object-fit: cover;
      /* The peak sits left of center in the upper third of the photo.
         These two numbers keep it in frame on wide AND narrow screens. */
      object-position: 42% 30%;
    }

    /* Scrim only on the bottom half: the sky and mountain stay untouched,
       the text sits on a dark base over the light roof-deck floor */
    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background: linear-gradient(to top, rgb(0 0 0 / 0.8) 0%, rgb(0 0 0 / 0.55) 35%, transparent 65%);
    }

    & .view-content {
      display: grid;
      gap: var(--space-s);
    }

    & .eyebrow {
      color: inherit;
    }

    & h2 {
      max-width: 16ch;
      text-shadow: 0 2px 20px rgb(0 0 0 / 0.3);
    }

    & p {
      font-size: var(--step-1);
      max-width: 45ch;
    }
  }

  /* ---------- Feature cards ---------- */
  .features {
    display: grid;
    gap: var(--space-m);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    padding: 0;
    list-style: none;
  }

  .feature {
    padding: var(--space-l);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-m);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;

    &:hover {
      border-color: var(--color-primary);
      box-shadow: var(--shadow-s);
    }

    & .icon {
      font-size: var(--step-2);
      line-height: 1;
      margin-block-end: var(--space-s);
    }

    & p {
      color: var(--color-ink-soft);
      margin-block-start: var(--space-2xs);
    }
  }

  /* ---------- Split (text + image) ---------- */
  .split {
    display: grid;
    gap: var(--space-xl);
    align-items: center;

    @media (width >= 56rem) {
      grid-template-columns: 1.1fr 1fr;
    }

    & .split-text {
      display: grid;
      gap: var(--space-m);
    }

    /* Landscape on phones (a tall crop filled the whole screen there),
       a bit squarer beside the text on desktop */
    & img {
      width: 100%;
      aspect-ratio: 3 / 2;
      object-fit: cover;
      border-radius: var(--radius-l);
      box-shadow: var(--shadow-m);

      @media (width >= 56rem) {
        aspect-ratio: 4 / 3;
      }
    }
  }

  /* ---------- "See more" inclusions (<details>) ---------- */
  .more-inclusions {
    margin-block-start: var(--space-xs);
    /* Lets the browser animate to/from height: auto (Chrome 129+).
       Other browsers simply open instantly. */
    interpolate-size: allow-keywords;

    & summary {
      display: inline-flex;
      align-items: center;
      gap: var(--space-xs);
      margin-block: var(--space-s);
      padding: var(--space-xs) var(--space-m);
      border: 2px solid var(--color-primary);
      border-radius: 999px;
      color: var(--color-primary);
      font-weight: 600;
      cursor: pointer;
      list-style: none; /* hide the default ▸ triangle */

      &::-webkit-details-marker { display: none; }

      /* Our own chevron, rotated when open */
      &::after {
        content: "";
        width: 0.5em;
        height: 0.5em;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        rotate: 45deg;
        translate: 0 -0.15em;
        transition: rotate 0.3s var(--ease-out), translate 0.3s var(--ease-out);
      }

      &:hover {
        background: color-mix(in oklab, var(--color-primary) 8%, transparent);
      }
    }

    /* Swap the label text with the open state */
    & .when-open { display: none; }
    &[open] .when-open { display: inline; }
    &[open] .when-closed { display: none; }
    &[open] summary::after {
      rotate: 225deg;
      translate: 0 0.15em;
    }

    /* ::details-content is the box holding everything except <summary>.
       Animate its height from 0 to auto; content-visibility needs
       allow-discrete so it stays visible until the closing slide ends. */
    &::details-content {
      block-size: 0;
      overflow: clip;
      transition: block-size 0.4s var(--ease-out),
        content-visibility 0.4s allow-discrete;
    }

    &[open]::details-content {
      block-size: auto;
    }
  }

  /* ---------- Touch vs mouse wording ----------
     (hover: none) = the main input can't hover, i.e. a finger. */
  .on-touch { display: none; }

  @media (hover: none) {
    .on-touch { display: inline; }
    .on-mouse { display: none; }
  }

  /* ---------- Checklist (inclusions) ---------- */
  .checklist {
    display: grid;
    gap: var(--space-xs) var(--space-l);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
    padding: 0;
    list-style: none;

    & li {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: var(--space-xs);
      align-items: start;

      &::before {
        content: "✓";
        display: grid;
        place-items: center;
        width: 1.5em;
        height: 1.5em;
        margin-block-start: 0.1em;
        border-radius: 50%;
        background: color-mix(in oklab, var(--color-primary) 15%, transparent);
        color: var(--color-primary);
        font-size: 0.85em;
        font-weight: 700;
      }
    }

    & small {
      display: block;
      color: var(--color-ink-soft);
    }
  }

  /* ---------- Info boxes (optional charges / not included) ---------- */
  .info-grid {
    display: grid;
    gap: var(--space-m);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    margin-block-start: var(--space-xl);
  }

  .info-box {
    padding: var(--space-l);
    border-radius: var(--radius-m);
    background: #fff;
    border-inline-start: 4px solid var(--box-color, var(--color-primary));

    &.warn {
      --box-color: var(--color-accent);
    }

    & h3 {
      margin-block-end: var(--space-xs);
    }

    & ul {
      padding-inline-start: 1.1em;
      display: grid;
      gap: var(--space-2xs);
    }
  }

  /* ---------- Contact ---------- */
  .contact-grid {
    display: grid;
    gap: var(--space-xl);

    @media (width >= 56rem) {
      grid-template-columns: 1fr 1.3fr;
    }

    & iframe {
      width: 100%;
      height: 100%;
      min-height: 22rem;
      border: 0;
      border-radius: var(--radius-l);
    }

    & dl {
      display: grid;
      gap: var(--space-m);
    }

    & dt {
      font-weight: 600;
      font-size: var(--step--1);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--color-ink-soft);
    }

    & dd {
      margin: 0;
      font-size: var(--step-1);
    }
  }

  .socials {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
  }

  /* ---------- Booking bar (pricing) ---------- */
  .book-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-m);
    margin-block-start: var(--space-l);
    padding: var(--space-m) var(--space-l);
    border-radius: var(--radius-l);
    background: color-mix(in oklab, var(--color-primary) 10%, white);

    & p {
      color: var(--color-ink);
      font-size: var(--step-0);
      margin: 0;
    }

    & .book-actions {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-xs);
    }

    & .btn-ghost {
      --btn-fg: var(--color-primary);
    }
  }

  /* ---------- CTA band ---------- */
  .cta {
    display: grid;
    justify-items: center;
    gap: var(--space-m);
    text-align: center;
  }

  /* ---------- Price cards ---------- */
  .price-list {
    display: grid;
    gap: var(--space-l);
  }

  .price-card-wrap {
    /* Makes this element a "container": children can query ITS width
       instead of the viewport's. */
    container: price-card / inline-size;
  }

  .price-card {
    display: grid;
    gap: var(--space-m);
    padding: var(--space-l);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-l);
    background: #fff;

    &:has(.badge) {
      border: 2px solid var(--color-accent);
      box-shadow: var(--shadow-m);
    }

    & .badge {
      justify-self: start;
      padding: var(--space-2xs) var(--space-s);
      border-radius: 999px;
      background: var(--color-accent);
      color: #fff;
      font-size: var(--step--1);
      font-weight: 600;
    }

    & .price-meta {
      display: grid;
      gap: var(--space-s);
      align-content: start;
    }

    & .btn {
      justify-content: center;
    }
  }

  /* Each rate is a row: label on the left, price on the right,
     with a dotted leader line filling the gap (like a menu). */
  .rate-rows {
    display: grid;
    gap: var(--space-xs);

    & div {
      display: flex;
      align-items: baseline;
      gap: var(--space-xs);

      &::after {
        content: "";
        flex: 1;
        order: 1;
        border-block-end: 2px dotted var(--color-line);
      }
    }

    & dt {
      color: var(--color-ink-soft);
    }

    & dd {
      order: 2;
      margin: 0;
      font-size: var(--step-2);
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      color: var(--color-ink);
    }
  }

  /* Several date ranges in one card (e.g. Holy Week): each range gets a
     small heading over its own rate rows, with a divider between ranges. */
  .rate-groups {
    display: grid;
    gap: var(--space-m);
  }

  .rate-group {
    display: grid;
    gap: var(--space-xs);

    & + & {
      padding-block-start: var(--space-m);
      border-block-start: 1px solid var(--color-line);
    }

    & h4 {
      margin: 0;
      font-size: var(--step--1);
      font-weight: 600;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      color: var(--color-accent);
    }
  }

  /* TODO(you): container query for the price cards.
     When the card's container is wide (think: desktop), lay the card out as a
     row of title | rate rows | button instead of one stacked column.
     Hints:
       @container price-card (width > ??rem) { .price-card { ... } }
       - grid-template-columns with 3 tracks, e.g. 1fr 1.5fr auto; align-items: center
       - Pick the breakpoint by resizing the window: where does it start
         looking cramped? That number is the design decision. */

  /* ---------- Period tabs (pricing) ----------
     Radio buttons do the "which one is selected" logic for free.
     :has() lets an ancestor (.rates) react to which radio is :checked. */
  .period-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin: 0 0 var(--space-l);
    padding: var(--space-2xs);
    border: 0;
    /* Not 999px: when the tabs wrap to 2 lines on phones, a full pill
       radius turns the box into a blob */
    border-radius: var(--radius-l);
    background: var(--color-surface-alt);
    width: fit-content;
    max-width: 100%;

    & label {
      padding: var(--space-xs) var(--space-m);
      border-radius: 999px;
      font-weight: 600;
      color: var(--color-ink-soft);
      cursor: pointer;
      transition: background-color 0.2s, color 0.2s;

      &:hover {
        color: var(--color-ink);
      }

      /* The label styles itself based on its own radio */
      &:has(:checked) {
        background: var(--color-primary);
        color: #fff;
      }

      /* Keyboard focus ring moves to the visible pill */
      &:has(:focus-visible) {
        outline: 3px solid var(--color-accent);
        outline-offset: 2px;
      }
    }

    /* Hide the native radio circle but keep it focusable and accessible */
    & input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
  }

  .period {
    display: none;
  }

  .rates:has(#p-dec:checked) [data-period="dec"],
  .rates:has(#p-hol:checked) [data-period="hol"],
  .rates:has(#p-jan:checked) [data-period="jan"],
  .rates:has(#p-feb:checked) [data-period="feb"],
  .rates:has(#p-mar:checked) [data-period="mar"],
  .rates:has(#p-apr:checked) [data-period="apr"],
  .rates:has(#p-may:checked) [data-period="may"] {
    display: block;
  }

  .period-notes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-l);
    margin-block-end: var(--space-m);
    padding: 0;
    list-style: none;
    color: var(--color-ink-soft);
    font-size: var(--step--1);

    & li::before {
      content: "• ";
      color: var(--color-accent);
    }
  }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* ---------- Photos page: jump links + groups ---------- */
  .jump-links {
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    margin-inline: calc(var(--space-m) * -1);
    padding: var(--space-s) var(--space-m);
    background: rgb(251 250 247 / 0.9);
    backdrop-filter: blur(10px);

    & ul {
      display: flex;
      gap: var(--space-xs);
      padding: 0;
      list-style: none;
      /* Phones: one swipeable row instead of wrapping into a tall block */
      overflow-x: auto;
      scrollbar-width: none;
    }

    & a {
      display: block;
      padding: var(--space-2xs) var(--space-m);
      border: 1px solid var(--color-line);
      border-radius: 999px;
      background: #fff;
      color: var(--color-ink);
      font-size: var(--step--1);
      font-weight: 600;
      text-decoration: none;
      white-space: nowrap;

      &:hover {
        border-color: var(--color-primary);
        color: var(--color-primary);
      }
    }
  }

  .gallery-group {
    padding-block-start: var(--space-l);
    /* Land below the sticky header AND the sticky jump links */
    scroll-margin-top: calc(var(--header-h) + 3.5rem);

    & h2 {
      font-size: var(--step-2);
      margin-block-end: var(--space-m);
    }
  }

  /* ---------- Gallery grid ----------
     Columns: auto-fill + minmax = "as many 16rem+ columns as fit", so it's
       1 column on phones, 2-3 on tablets, 4 on desktop, with no media queries.
     Rows: a fixed height, so every photo is cropped to the same row height.
       (If rows were "auto", a tall 4000px photo would stretch its row.)
     dense: lets later small photos backfill holes left by wide/tall ones. */
  .gallery {
    display: grid;
    gap: var(--space-s);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
    grid-auto-rows: clamp(11rem, 16vw, 14rem);
    grid-auto-flow: dense;
    padding: 0;
    list-style: none;

    & .tall {
      grid-row: span 2;
    }

    /* Only span 2 columns when there ARE 2 columns. On a 1-column phone,
       span 2 would create a phantom column and overflow sideways. */
    @media (width >= 36rem) {
      & .wide {
        grid-column: span 2;
      }
    }

    & button {
      display: block;
      width: 100%;
      height: 100%;
      padding: 0;
      border: 0;
      border-radius: var(--radius-m);
      overflow: clip;
      cursor: zoom-in;
      background: var(--color-surface-alt);
    }

    & img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: scale 0.5s var(--ease-out);
    }

    & button:hover img {
      scale: 1.05;
    }
  }

  /* ---------- Lightbox (<dialog>) ----------
     The dialog covers the whole screen (transparent) and centers the photo.
     The photo then sizes itself from its own shape: wide panoramas get wide,
     portrait shots get tall, with no black bars and no cropping. */
  .lightbox {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    /* Our reset (* { margin: 0 }) removes the browser's margin: auto,
       which is what centers a <dialog>. Put it back. */
    margin: auto;
    padding: var(--space-m);
    border: 0;
    background: transparent;
    color: #fff;

    &[open] {
      display: grid;
      place-items: center;
    }

    &::backdrop {
      background: rgb(0 0 0 / 0.88);
      backdrop-filter: blur(4px);
    }

    & figure {
      display: grid;
      justify-items: center;
      gap: var(--space-s);
    }

    & img {
      width: auto;
      max-width: min(100%, 90rem);
      /* leave room for the caption below */
      max-height: calc(100svh - 7rem);
      border-radius: var(--radius-m);
      box-shadow: 0 20px 60px rgb(0 0 0 / 0.5);
    }

    & figcaption {
      text-align: center;
      font-size: var(--step--1);
      opacity: 0.85;
    }

    & .lightbox-btn {
      position: fixed;
      display: grid;
      place-items: center;
      width: 3rem;
      height: 3rem;
      border: 0;
      border-radius: 50%;
      background: rgb(255 255 255 / 0.9);
      color: var(--color-ink);
      font-size: 1.5rem;
      cursor: pointer;
      transition: background-color 0.2s, scale 0.2s;

      &:hover {
        background: #fff;
        scale: 1.08;
      }

      &.close { top: var(--space-m); right: var(--space-m); }
      &.prev { left: var(--space-m); top: 50%; translate: 0 -50%; }
      &.next { right: var(--space-m); top: 50%; translate: 0 -50%; }

      /* Phones: arrows move to the bottom corners, off the photo.
         Swiping (js/gallery.js) is the main way to browse there. */
      @media (width < 48rem) {
        &.prev,
        &.next {
          top: auto;
          bottom: var(--space-m);
          translate: none;
        }
      }
    }

    /* Let the browser keep vertical scrolling/zoom gestures, but hand
       horizontal swipes to our script */
    touch-action: pan-y pinch-zoom;

    /* Fade + scale on open. @starting-style is the "before" state of an
       entry animation, so the dialog animates in from it when it opens. */
    & figure {
      transition: opacity 0.25s, scale 0.25s var(--ease-out);
    }

    @starting-style {
      &[open] figure {
        opacity: 0;
        scale: 0.96;
      }
    }
  }
}
