/* ==========================================================================
   COURAGEOUS — Interactive layer
   Loaded after main.css. Everything here is mobile-first: the base rules are
   the phone layout, and min-width queries add desktop on top.

   16. Mobile action bar        19. Lightbox
   17. Before / after slider    20. Micro-interactions
   18. Estimate configurator    21. Mobile-first overrides
   ========================================================================== */

/* 16. MOBILE ACTION BAR ==================================================
   Research-backed: primary actions live in the bottom third of the screen
   (the thumb zone), minimum 48px tall, with outcome-specific copy.
   ======================================================================== */
.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 95;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255,255,255,.14);
  padding-bottom: env(safe-area-inset-bottom, 0);
  transform: translateY(110%);
  transition: transform .45s var(--ease-out-expo);
  box-shadow: 0 -8px 32px -12px rgba(20,13,9,.55);
}
.action-bar.is-visible { transform: translateY(0); }
.action-bar.is-parked  { transform: translateY(110%); }

.action-bar__btn {
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 58px;
  padding: .9rem 1rem;
  font-family: var(--font-body);
  font-size: .82rem; font-weight: 600; letter-spacing: .06em;
  text-decoration: none; text-align: center;
  transition: background .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.action-bar__btn--call  { background: var(--copper-900); color: #fff; }
.action-bar__btn--quote { background: var(--lion); color: #fff; }
.action-bar__btn:active { filter: brightness(1.15); }
.action-bar__btn svg { flex: none; }
.action-bar__btn small {
  display: block; font-size: .62rem; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; opacity: .7; margin-bottom: .1rem;
}
.action-bar__label { display: grid; text-align: left; line-height: 1.15; }

@media (min-width: 981px) { .action-bar { display: none; } }
/* Keep the last section clear of the bar */
@media (max-width: 980px) { .site-footer { padding-bottom: 76px; } }

/* 17. BEFORE / AFTER SLIDER =============================================
   The single highest-converting element on a remodeling site. Drag, touch,
   click-to-position and full keyboard support.
   ======================================================================== */
.compare {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--copper-800);
  touch-action: pan-y;          /* let the page scroll vertically past it */
  user-select: none;
  cursor: ew-resize;
  isolation: isolate;
}
.compare--wide { aspect-ratio: 16 / 10; }

.compare__layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
}
.compare__layer--after  { background-image: var(--after); }
.compare__layer--before {
  background-image: var(--before);
  /* Revealed portion is driven by --pos (0-100) set from JS */
  clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0);
}

.compare__handle {
  position: absolute; top: 0; bottom: 0;
  left: var(--pos, 50%);
  width: 2px; margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(20,13,9,.25), 0 0 22px rgba(20,13,9,.5);
  z-index: 3;
}
.compare__grip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: #fff; color: var(--copper-900);
  display: grid; place-items: center;
  box-shadow: 0 6px 22px rgba(20,13,9,.4);
  transition: transform .25s var(--ease-out-expo);
}
.compare:hover .compare__grip,
.compare:focus-within .compare__grip { transform: translate(-50%, -50%) scale(1.08); }
.compare__grip svg { display: block; }

.compare__tag {
  position: absolute; top: 1rem; z-index: 4;
  padding: .4rem .8rem;
  font-size: .64rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  background: rgba(20,13,9,.72); color: #fff;
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.compare__tag--before { left: 1rem; }
.compare__tag--after  { right: 1rem; }

.compare__hint {
  position: absolute; left: 50%; bottom: 1rem; z-index: 4;
  transform: translateX(-50%);
  padding: .45rem .9rem;
  background: rgba(20,13,9,.72); color: #fff;
  backdrop-filter: blur(6px);
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  pointer-events: none;
  transition: opacity .4s var(--ease);
}
.compare.is-touched .compare__hint { opacity: 0; }

/* Invisible range input carries keyboard + screen-reader semantics */
.compare__range {
  position: absolute; inset: 0; z-index: 5;
  width: 100%; height: 100%;
  opacity: 0; margin: 0; cursor: ew-resize;
  -webkit-appearance: none; appearance: none; background: transparent;
}
.compare__range:focus-visible ~ .compare__handle .compare__grip {
  outline: 3px solid var(--lion); outline-offset: 3px;
}

/* 18. ESTIMATE CONFIGURATOR =============================================
   A multi-step chooser that builds a roof profile and hands it to the
   request form. It deliberately quotes no construction prices — only the
   published estimate fee — so nothing on it can be wrong.
   ======================================================================== */
.config {
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
}
.config__bar { height: 3px; background: var(--line-soft); position: relative; }
.config__bar span {
  position: absolute; inset: 0 auto 0 0;
  background: var(--lion);
  width: var(--progress, 25%);
  transition: width .5s var(--ease-out-expo);
}
.config__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: var(--sp-4) var(--sp-4) 0;
}
.config__step-no {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .14em;
  color: var(--accent-ink);
}
.config__panel { padding: var(--sp-4); display: none; }
.config__panel.is-active { display: block; animation: cfg-in .45s var(--ease-out-expo) both; }
@keyframes cfg-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

.config__q { margin-bottom: var(--sp-4); }
.config__opts { display: grid; gap: .6rem; }
@media (min-width: 620px) { .config__opts--2 { grid-template-columns: 1fr 1fr; } }

.opt {
  display: flex; align-items: flex-start; gap: .85rem;
  width: 100%; text-align: left;
  min-height: 56px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--bg);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { border-color: var(--lion); }
.opt:active { transform: scale(.99); }
.opt.is-picked { border-color: var(--lion); background: rgba(154,84,51,.07); }
.opt__mark {
  flex: none; width: 20px; height: 20px; margin-top: .15rem;
  border: 1px solid var(--line); border-radius: 50%;
  display: grid; place-items: center;
  transition: border-color .2s, background .2s;
}
.opt.is-picked .opt__mark { border-color: var(--lion); background: var(--lion); }
.opt__mark svg { opacity: 0; transition: opacity .2s; }
.opt.is-picked .opt__mark svg { opacity: 1; }
.opt__body strong { display: block; font-weight: 600; font-size: .95rem; }
.opt__body span { display: block; font-size: .84rem; color: var(--fg-muted); margin-top: .12rem; }

.config__nav {
  display: flex; gap: .7rem; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--line-soft);
}
.config__back {
  font-size: .74rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg-muted); padding: .6rem 0;
}
.config__back:hover { color: var(--fg); }
.config__back[hidden] { visibility: hidden; display: block; }

.config__summary { display: grid; gap: .7rem; }
.config__row {
  display: flex; justify-content: space-between; gap: 1rem;
  padding-block: .7rem; border-bottom: 1px solid var(--line-soft);
  font-size: .9rem;
}
.config__row dt { color: var(--fg-muted); }
.config__row dd { margin: 0; font-weight: 600; text-align: right; }
.config__fee {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.config__fee strong { font-family: var(--font-display); font-size: 2.2rem; letter-spacing: -.03em; }

/* 19. LIGHTBOX ========================================================== */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(13,8,6,.96);
  display: none;
  place-items: center;
  padding: env(safe-area-inset-top, 1rem) 1rem env(safe-area-inset-bottom, 1rem);
}
.lightbox.is-open { display: grid; animation: lb-in .3s var(--ease) both; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

.lightbox__stage {
  position: relative;
  width: min(1200px, 100%);
  aspect-ratio: 4 / 3;
  background-size: contain; background-position: center; background-repeat: no-repeat;
  touch-action: pan-y;
}
.lightbox__cap {
  position: absolute; left: 0; right: 0; bottom: -3.2rem;
  text-align: center; color: rgba(255,255,255,.82); font-size: .85rem;
}
.lightbox__cap strong { color: #fff; display: block; font-weight: 600; }

.lightbox__close, .lightbox__nav {
  position: absolute; z-index: 2;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  backdrop-filter: blur(6px);
  transition: background .2s, transform .2s;
}
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255,255,255,.22); }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__nav--prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox__count {
  position: absolute; top: 1.4rem; left: 1.2rem;
  font-family: var(--font-mono); font-size: .78rem; color: rgba(255,255,255,.72);
}
@media (max-width: 640px) {
  .lightbox__nav { bottom: 1rem; top: auto; transform: none; }
  .lightbox__nav--prev { left: 1rem; }
  .lightbox__nav--next { right: 1rem; }
}

/* 20. MICRO-INTERACTIONS ================================================
   Deliberately few. Research is consistent that 3-5 purposeful motions read
   as premium and 20 read as chaos.
   ======================================================================== */

/* (1) Reading progress — thin, only on long pages */
.progress-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 101; background: transparent; pointer-events: none;
}
.progress-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--lion), var(--lion-300));
  transition: width .1s linear;
}

/* (2) Magnetic buttons — pointer devices only, never on touch */
@media (hover: hover) and (pointer: fine) {
  .btn, .action-bar__btn { transition: background .25s var(--ease), color .25s var(--ease),
                                       border-color .25s var(--ease), transform .25s var(--ease-out-expo); }
  .btn[data-magnetic] { will-change: transform; }
}

/* (3) Tap feedback — touch devices, replaces hover */
@media (hover: none) {
  .btn:active, .card:active, .project:active, .area:active { transform: scale(.985); }
}

/* (4) Image parallax depth inside media frames */
.media[data-parallax] { background-position: center calc(50% + var(--shift, 0px)); }

/* (5) Sequential stat counting is already handled in main.js */

/* 21. MOBILE-FIRST OVERRIDES ============================================
   The base experience is the phone. These correct things that were designed
   desktop-down.
   ======================================================================== */
@media (max-width: 640px) {
  /* Bigger, more readable body copy on small screens */
  :root { --step-0: 1.02rem; }
  body { line-height: 1.7; }

  /* Every interactive target clears the 48px minimum */
  .btn { min-height: 52px; }
  .nav__toggle { width: 52px; height: 52px; }
  .filter { min-height: 46px; padding-inline: 1.1rem; }
  .accordion__trigger { min-height: 60px; }
  .footer__list a { display: inline-block; padding-block: .35rem; }
  .socials a { width: 48px; height: 48px; }
  .slider-nav button { width: 52px; height: 52px; }

  /* Hero: tighter and punchier, CTA above the fold where possible */
  .hero { min-height: 78svh; }
  .hero__title { max-width: 100%; }
  .hero__text { font-size: 1.02rem; }
  .hero__bar { margin-top: var(--sp-5); }
  .hero__bar-grid > * { padding: var(--sp-3) var(--sp-2); }
  .stat__value { font-size: 2rem; }
  .stat__label { font-size: .64rem; letter-spacing: .1em; }

  /* Section rhythm tightened so scrolling is not endless */
  .section { padding-block: 3.4rem; }
  .section-head { margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); }

  /* Cards get breathing room but less dead space */
  .card { padding: 1.3rem; }
  .compare { aspect-ratio: 3 / 4; }      /* portrait reads better on a phone */
  .compare__grip { width: 46px; height: 46px; }
  .compare__tag { font-size: .58rem; padding: .3rem .6rem; }

  /* Sticky sidebars must not stick on a phone */
  .card[style*="sticky"] { position: static !important; }
}

@media (max-width: 980px) {
  /* The mobile drawer becomes a proper thumb-friendly menu */
  .mobile-nav__link { padding: 1.05rem 0; font-size: 1.6rem; }
  .mobile-nav__foot { position: sticky; bottom: 0; padding-top: var(--sp-3); }
}

/* Respect the platform: no motion for users who asked for none */
@media (prefers-reduced-motion: reduce) {
  .action-bar { transition: none; }
  .config__panel.is-active { animation: none; }
  .lightbox.is-open { animation: none; }
  .progress-bar span { transition: none; }
}

/* 22. REAL <img> RENDERING ==============================================
   Images are now real <img> elements rather than CSS background-images set
   through a custom property. A background driven by var(--img) is invisible
   to devtools, to the network panel and to screen readers, and it silently
   renders nothing when anything upstream goes wrong. An <img> either shows
   or reports a broken file.
   ======================================================================== */
.media { display: block; }
.media > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.hero, .page-hero { position: relative; }
.hero__bg, .page-hero__bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  display: block;
}
/* The scrim must sit above the photo but below the copy. */
.hero::after, .page-hero::after { z-index: 1; }
.hero__inner, .page-hero__inner, .hero__bar, .hero__scroll { z-index: 2; }

/* Compare slider layers are images now, clipped the same way. */
.compare__layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.compare__layer--after  { z-index: 0; }
.compare__layer--before { z-index: 1; clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
