/* Âmbar — car project page composition ("dossiê").
   Implements references/car-project-layout.md of the ambar-design skill.
   Requires ambar-tokens.css. Own layout — nothing shared with other themes. */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body { overflow-x: clip; }
img { max-width: 100%; height: auto; display: block; }
a, button { -webkit-tap-highlight-color: rgba(228,180,108,.25); touch-action: manipulation; }

.ab-wrap { max-width: 1200px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 640px) { .ab-wrap { padding-inline: 32px; } }
@media (min-width: 1024px) { .ab-wrap { padding-inline: 56px; } }

#capitulo, #arquivo, #fotos { scroll-margin-top: 48px; }

.ab-skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--am-amber); color: var(--am-ink);
  padding: 10px 14px; font-family: var(--am-font-poster); font-weight: 700; text-decoration: none; }
.ab-skip:focus-visible { top: 12px; }

/* ============ 0 · STATUS STRIP ============ */
.ab-strip { position: sticky; top: 0; z-index: 30; background: var(--am-char-solid);
  border-bottom: 1px solid var(--am-char-2); padding-top: env(safe-area-inset-top, 0px); }
.ab-strip__inner { height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ab-strip__name { font-family: var(--am-font-poster); font-weight: 800; font-size: 1.125rem; letter-spacing: .06em;
  text-transform: uppercase; }
.ab-strip__case { display: none; font-family: var(--am-font-term); font-size: .6875rem; letter-spacing: .06em;
  color: var(--am-paper-mute); }
.ab-strip__links { display: none; gap: 24px; }
.ab-strip__links a { font-family: var(--am-font-poster); font-weight: 600; font-size: .8125rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--am-dash-text); text-decoration: none; padding: 12px 0;
  border-bottom: 2px solid transparent; transition: color var(--am-t-hover), border-color var(--am-t-hover); }
.ab-strip__links a[aria-current="true"] { color: var(--am-amber); border-color: var(--am-amber); }
@media (hover: hover) and (pointer: fine) { .ab-strip__links a:hover { color: var(--am-amber); } }
@media (min-width: 768px) { .ab-strip__case { display: block; } }
@media (min-width: 1024px) { .ab-strip__links { display: flex; } .ab-strip__menu { display: none; } }

.ab-menu { position: fixed; inset: 0; z-index: 60; outline: none; display: flex; flex-direction: column; }
.ab-menu[hidden] { display: none; }
.ab-menu .am-term__body { flex: 1; }
.ab-menu__item { display: block; color: var(--am-term); text-decoration: none; font-size: 1rem; padding: 14px 0;
  border-bottom: 1px solid var(--am-term-line); }
.ab-menu__item:active, .ab-menu__item:focus-visible { background: var(--am-term-fill); outline: none; }

/* ============ 1 · POSTER + DASH DOCK ============ */
/* Title band ABOVE the photo: a car usually spans the full width of its photo, so there is no safe place to
   set a headline on the image itself. The poster reads headline → photo → cluster. */
.ab-poster { position: relative; }
.ab-poster__card { padding-block: 28px 18px; position: relative; z-index: 3; }
@media (min-width: 1024px) {
  .ab-poster__card { padding-block: 56px 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
  .ab-poster__card .am-kicker { order: 2; text-align: right; margin: 0 0 14px; max-width: 30ch; }
}
.ab-poster__card .am-kicker { margin: 0 0 6px; }
.ab-name { margin: 0; font-family: var(--am-font-poster); font-weight: 800; text-transform: uppercase;
  letter-spacing: -.015em; line-height: .82; font-size: clamp(3.5rem, 17vw, 10rem); color: var(--am-paper); }

.ab-poster__frame { position: relative; }
.ab-poster__photo { margin: 0; width: 100%; aspect-ratio: 4 / 3; max-height: 78vh; max-height: 78svh; background: var(--am-soot); }
.ab-poster__photo img { object-position: center 60%; }
/* the 78svh cap turns this into a ~2:1 band on desktop, so the poster switches to the
   side-profile shot, where trimming sky and asphalt never touches the car */
@media (min-width: 1024px) { .ab-poster__photo img { object-position: center 55%; } }
.ab-poster__photo::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(11,9,6,.35) 0%, transparent 18%, transparent 80%, rgba(11,9,6,.7) 100%); }

.ab-ink { position: absolute; fill: var(--am-ink); pointer-events: none; }
/* bridges the title band and the photo on the right edge */
.ab-ink--poster { width: clamp(80px, 20vw, 200px); right: -10px; top: -34px; z-index: 2; transform: rotate(18deg); }

/* dash dock overlaps the poster's bottom edge */
.ab-dock-wrap { position: relative; z-index: 4; margin-top: -32px; }
@media (min-width: 1024px) { .ab-dock-wrap { margin-top: -56px; } }
.ab-dock { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; padding: 0; background: var(--am-char-2);
  border: 1px solid var(--am-char-2); box-shadow: 0 16px 40px rgba(0,0,0,.5); }
@media (min-width: 1024px) { .ab-dock { grid-template-columns: repeat(4, 1fr); } }
.ab-gauge { background: var(--am-char-solid); padding: 12px 14px 14px; position: relative; overflow: hidden; }
.ab-gauge::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--am-amber-deep), transparent); }
.ab-gauge__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ab-gauge .am-unit { margin: 0; }
.ab-gauge .am-lcd { font-size: clamp(2.25rem, 10vw, 3.5rem); }
@media (min-width: 1024px) { .ab-gauge { padding: 16px 20px 18px; } .ab-gauge .am-lcd { font-size: 3.5rem; } }
.ab-gauge__delta { margin-top: 6px; font-family: var(--am-font-poster); font-weight: 600; font-size: .8125rem;
  color: var(--am-go); letter-spacing: .06em; }

/* ============ 2 · CAPÍTULO ============ */
.ab-chapter { background: var(--am-soot); padding-block: 72px 88px; margin-top: 48px; }
.ab-chapter__grid { position: relative; z-index: 2; display: flex; flex-direction: column-reverse; gap: 48px; }
@media (min-width: 1024px) {
  .ab-chapter__grid { display: grid; grid-template-columns: 5fr 7fr; gap: 64px; align-items: start; }
}
.ab-pasted { position: relative; margin: 0; max-width: 360px; transform: rotate(-2deg); justify-self: start; }
@media (min-width: 1024px) { .ab-pasted { max-width: none; margin-top: 24px; } }
.ab-pasted__photo { aspect-ratio: 4 / 5; box-shadow: 0 18px 40px rgba(0,0,0,.55); border: 6px solid var(--am-paper); }
.ab-tape { position: absolute; z-index: 2; top: -12px; left: 50%; width: 96px; height: 26px; transform: translateX(-50%) rotate(3deg);
  background: rgba(208,186,138,.55); box-shadow: 0 1px 2px rgba(0,0,0,.25); }

.ab-chapter__text .am-poster { margin: 6px 0 24px; }
.ab-fields { list-style: none; margin: 0 0 28px; padding: 0 0 20px; border-bottom: 1px solid var(--am-sepia-lo);
  display: grid; gap: 4px; }
.ab-fields li { font-family: var(--am-font-poster); font-weight: 700; font-size: 1.0625rem; color: var(--am-paper); }
.ab-fields li span { color: var(--am-paper-mute); font-weight: 600; margin-right: 6px; }
.ab-story { max-width: 62ch; }
.ab-story p { margin: 0 0 16px; font-size: 1rem; line-height: 1.65; color: var(--am-paper-dim); text-wrap: pretty; }
.ab-story p:first-child { font-size: 1.1875rem; line-height: 1.5; color: var(--am-paper); }
.ab-sign { margin: 20px 0 0; }

/* ============ 3 · ARQUIVO ============ */
.ab-file { padding-block: 72px; }
.ab-term__grid { display: flex; flex-direction: column; }
@media (min-width: 1024px) { .ab-term__grid { display: grid; grid-template-columns: 1fr 280px; } }
.ab-typed { overflow: hidden; white-space: nowrap; }
/* balanced 2-column flow on wide screens: blocks never split, no empty column */
.ab-specs { column-gap: 40px; }
@media (min-width: 768px) { .ab-specs { columns: 2; } }
.ab-specs__block { break-inside: avoid; padding-bottom: 8px; }
.ab-specs__block > .am-term__label { margin-top: 12px; }
.ab-parts .am-term__row > :nth-child(2) { flex: 1; text-align: left; color: var(--am-term); }
.ab-anexos { border-top: 1px solid var(--am-term-line); padding: 16px; }
@media (min-width: 1024px) { .ab-anexos { border-top: 0; border-left: 1px solid var(--am-term-line); } }
.ab-anexos .am-term__label { margin-top: 0; }
.ab-anexos__list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 1024px) { .ab-anexos__list { grid-template-columns: 1fr; gap: 12px; } }
.ab-anexo { display: block; padding: 0; border: 1px solid var(--am-term-line); background: none; cursor: pointer; text-align: left;
  color: var(--am-term-dim); font: inherit; }
.ab-anexo .am-graded { aspect-ratio: 1; }
/* stays square on every width: the source thumbs are square, so a 16:9 cell was
   slicing 44% off each attachment and cutting the car in half */
.ab-anexo span { display: block; padding: 5px 6px; font-size: .625rem; }
.ab-anexo:hover, .ab-anexo:focus-visible { border-color: var(--am-term); color: var(--am-term); outline: none; }

/* ============ 4 · FOLHA DE CONTATO ============ */
.ab-sheet { background: var(--am-soot); padding-block: 72px 88px; }
.ab-sheet .ab-wrap { position: relative; z-index: 2; }
.ab-sheet .am-poster { margin: 6px 0 32px; }
.ab-sheet__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 10px; }
@media (min-width: 640px) { .ab-sheet__grid { grid-template-columns: repeat(3, 1fr); gap: 28px 16px; } }
@media (min-width: 1024px) { .ab-sheet__grid { grid-template-columns: repeat(4, 1fr); } }
.ab-frame { position: relative; padding: 0 0 8px; border: 0; background: none; cursor: pointer; text-align: left;
  border-bottom: 1px solid var(--am-sepia-lo); color: var(--am-paper-mute); font-family: var(--am-font-term); font-size: .6875rem;
  transition: transform var(--am-t-hover), border-color var(--am-t-hover), color var(--am-t-hover); }
.ab-frame .am-graded { aspect-ratio: 1; margin-bottom: 6px; }
.ab-frame__num { letter-spacing: .08em; }
@media (hover: hover) and (pointer: fine) { .ab-frame:hover { border-color: var(--am-amber); color: var(--am-amber); } }
.ab-frame:active { transform: scale(.97); }
.ab-frame:focus-visible { outline: 2px solid var(--am-amber); outline-offset: 4px; }
.ab-frame--fav::after { content: ""; position: absolute; inset: -10px -8px 14px -8px; pointer-events: none;
  border: 2px solid var(--am-amber); border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%; transform: rotate(-4deg); opacity: .9; }

/* reveal ("develop") */
.ab-develop { opacity: 0; }
.ab-develop.is-in { opacity: 1; animation: ab-develop var(--am-t-develop) both; }
@keyframes ab-develop { from { opacity: .25; filter: brightness(1.6) saturate(.4); } to { opacity: 1; filter: none; } }
.ab-cut { opacity: 0; }
.ab-cut.is-in { opacity: 1; }

/* ============ LIGHTBOX ============ */
.ab-lightbox { border: 0; padding: 0; background: transparent; color: var(--am-paper);
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; overflow: hidden; overscroll-behavior: contain; }
.ab-lightbox::backdrop { background: rgba(11,9,6,.92); }
.ab-lightbox__siren { position: absolute; top: 0; left: 0; right: 0; }
.ab-lightbox__inner { height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 16px 12px 12px; }
.ab-lightbox__stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.ab-lightbox__stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border: 1px solid var(--am-paper-mute); }
.ab-lightbox__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ab-lightbox__count { font-family: var(--am-font-term); font-size: .75rem; color: var(--am-paper-dim); margin-right: auto; margin-left: 12px; }
.ab-lb-btn { min-width: 44px; height: 44px; border: 1px solid var(--am-paper-mute); background: var(--am-char-solid); color: var(--am-amber);
  font-size: 1.5rem; line-height: 1; cursor: pointer; border-radius: 2px; }
.ab-lb-btn:active { background: var(--am-char-2); }
.ab-lb-btn:focus-visible { outline: 2px solid var(--am-amber); outline-offset: 2px; }
.ab-lb-side { display: none; }
@media (min-width: 768px) {
  .ab-lightbox__inner { padding: 28px 40px 20px; }
  .ab-lb-side { display: block; position: absolute; top: 50%; transform: translateY(-50%); }
  .ab-lb-side.ab-lb-prev { left: 0; } .ab-lb-side.ab-lb-next { right: 0; }
  .ab-lightbox__stage { padding-inline: 60px; }
  .ab-lightbox__bar .ab-lb-prev, .ab-lightbox__bar .ab-lb-next { display: none; }
  .ab-lightbox__count { margin-left: 0; }
}

/* ============ 5 · CASE CARD ============ */
.ab-foot { padding-block: 72px calc(48px + env(safe-area-inset-bottom, 0px)); }
.ab-foot__grid { display: flex; flex-direction: column; gap: 24px; align-items: flex-start; }
@media (min-width: 1024px) { .ab-foot__grid { flex-direction: row; align-items: flex-end; justify-content: space-between; } }
.ab-case { width: 100%; max-width: 340px; }
.ab-case__body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ab-case__qr { background: #F4F1EA; padding: 10px; width: 180px; }
.ab-case__url { margin: 0; font-size: .625rem; text-transform: none; word-break: break-all; text-align: center; color: var(--am-term-dim); }
.ab-credit { margin: 0; font-family: var(--am-font-poster); font-weight: 600; font-size: 1rem; color: var(--am-paper-mute); }
.ab-credit a { color: var(--am-amber); text-decoration: none; border-bottom: 1px solid var(--am-amber-deep); }

@media (prefers-reduced-motion: reduce) {
  .ab-develop, .ab-cut { opacity: 1 !important; }
}
