/* Braventon - components: icons, buttons, forms, product tile, chips, cart, modal, toast. */
@layer components {
  .bv-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: square; stroke-linejoin: miter; flex: none; }
  .bv-icon--sm { width: 18px; height: 18px; }
  .bv-icon [data-fill] { fill: currentColor; stroke: none; }

  /* ---------- buttons ---------- */
  .bv-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .6rem; min-height: 50px; padding: .7rem 1.5rem;
    background: var(--color-cone); color: #fff; text-decoration: none; cursor: pointer;
    border: var(--bw) solid var(--color-ink); border-radius: var(--r); box-shadow: var(--shadow-hard-sm);
    font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: .06em; text-transform: uppercase; line-height: 1;
    transition: transform .14s var(--ease), box-shadow .14s var(--ease), background .15s;
  }
  .bv-btn:hover { background: var(--color-cone-deep); color: #fff; transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--color-ink); }
  .bv-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--color-ink); }
  .bv-btn:disabled, .bv-btn[aria-busy="true"] { opacity: .65; pointer-events: none; }
  .bv-btn--ghost { background: var(--color-paper); color: var(--color-ink); }
  .bv-btn--ghost:hover { background: var(--color-tape); color: var(--color-ink); }
  .bv-btn--tape { background: var(--color-tape); color: var(--color-ink); }
  .bv-btn--tape:hover { background: #ffd23d; color: var(--color-ink); }
  .bv-btn--on-dark { border-color: var(--color-on-rebar); box-shadow: 3px 3px 0 var(--color-on-rebar); }
  .bv-btn--on-dark:hover { box-shadow: 5px 5px 0 var(--color-on-rebar); }
  .bv-btn--sm { min-height: 42px; padding: .5rem 1rem; font-size: 1rem; }
  .bv-btn--block { width: 100%; }
  .bv-btn[data-state="added"] { background: var(--color-ok); }
  .bv-link { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--color-cone-deep); }

  /* ---------- forms ---------- */
  .bv-field { display: grid; gap: .4rem; margin-bottom: 1.1rem; }
  .bv-field label, .bv-field legend { font-family: var(--font-mono); font-size: var(--fs--1); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
  .bv-opt { text-transform: none; letter-spacing: 0; color: var(--color-steel); font-weight: 400; }
  .bv-input, .bv-select, .bv-textarea {
    width: 100%; min-height: 50px; padding: .7rem .9rem; background: var(--color-paper); color: var(--color-ink);
    border: var(--bw) solid var(--color-ink); border-radius: var(--r); transition: box-shadow .14s;
  }
  .bv-textarea { min-height: 120px; resize: vertical; }
  .bv-input::placeholder, .bv-textarea::placeholder { color: #6b7279; }
  .bv-input:focus, .bv-select:focus, .bv-textarea:focus { outline: none; box-shadow: 4px 4px 0 var(--color-cone); }
  .bv-input[aria-invalid="true"], .bv-select[aria-invalid="true"], .bv-textarea[aria-invalid="true"] { border-color: var(--color-error); box-shadow: 4px 4px 0 var(--color-error); }
  .bv-select { appearance: none; padding-right: 2.5rem; background-image: linear-gradient(45deg, transparent 50%, var(--color-ink) 50%), linear-gradient(135deg, var(--color-ink) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
  .bv-upper { text-transform: uppercase; }
  .bv-error { color: var(--color-error); font-size: .875rem; font-weight: 600; }
  .bv-note { font-size: .875rem; color: var(--color-steel); }
  .bv-note a { color: var(--color-cone-deep); }
  .bv-formrow { display: grid; gap: 0 1rem; }
  .bv-formrow--2 { grid-template-columns: repeat(2, 1fr); }
  .bv-formrow--3 { grid-template-columns: 1.4fr 1fr 1fr; }
  fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; min-width: 0; }
  fieldset > legend { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; text-transform: uppercase; padding: 0; margin-bottom: 1rem; width: 100%; border-bottom: var(--bw) solid var(--color-ink); letter-spacing: .02em; }
  .bv-alert { padding: .85rem 1rem; margin-bottom: 1rem; border: var(--bw) solid; font-weight: 600; font-size: .9375rem; }
  .bv-alert--error { border-color: var(--color-error); color: var(--color-error); background: #fff; }
  .bv-alert--ok { border-color: var(--color-ok); color: var(--color-ok); background: #fff; }
  @media (max-width: 639.98px) { .bv-formrow--2, .bv-formrow--3 { grid-template-columns: 1fr; } }

  .bv-panel { background: var(--color-paper); border: var(--bw) solid var(--color-ink); padding: clamp(1.25rem, 3vw, 2rem); box-shadow: var(--shadow-hard); }

  /* ---------- loader: three bars rising like scaffolding ---------- */
  .bv-loader { display: inline-flex; gap: 3px; align-items: flex-end; height: 16px; }
  .bv-loader i { width: 4px; background: currentColor; animation: bv-rise .9s var(--ease) infinite; height: 40%; }
  .bv-loader i:nth-child(2) { animation-delay: .15s; }
  .bv-loader i:nth-child(3) { animation-delay: .3s; }
  @keyframes bv-rise { 0%, 100% { height: 30%; } 50% { height: 100%; } }

  /* ---------- product tile ---------- */
  /* 3D tilt tile: wrapper owns perspective, card rotates, media and body sit on different depths */
  .bv-tilt3d { perspective: 1000px; height: 100%; }
  .bv-tile {
    --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 0%;
    position: relative; display: flex; flex-direction: column; height: 100%; background: var(--color-paper);
    border: var(--bw) solid var(--color-ink); transform-style: preserve-3d;
    transform: rotateX(var(--rx)) rotateY(var(--ry));
    transition: transform .35s var(--ease), box-shadow .35s var(--ease);
    box-shadow: 0 1px 0 var(--color-ink), 0 10px 0 -4px rgb(23 26 29 / .18), 0 24px 40px -18px rgb(23 26 29 / .45);
  }
  .bv-tile.is-tilting { transition: transform .06s linear, box-shadow .2s; box-shadow: 0 2px 0 var(--color-ink), 0 18px 0 -6px rgb(23 26 29 / .16), 0 40px 50px -16px rgb(23 26 29 / .55); }
  .bv-tile::before { /* folded corner */
    content: ""; position: absolute; top: -2px; right: -2px; width: var(--cut); height: var(--cut); z-index: 3;
    background: linear-gradient(225deg, var(--color-bone) 50%, var(--color-ink) 50%); transform: translateZ(40px);
  }
  .bv-tile::after { /* glare following the pointer */
    content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .25s;
    background: radial-gradient(420px circle at var(--gx) var(--gy), rgb(255 255 255 / .38), transparent 55%); mix-blend-mode: soft-light;
  }
  .bv-tile.is-tilting::after { opacity: 1; }
  .bv-tile__media { position: relative; transform: translateZ(18px); box-shadow: 0 10px 18px -8px rgb(23 26 29 / .5); aspect-ratio: 4 / 3; background: var(--color-concrete); border-bottom: var(--bw) solid var(--color-ink); overflow: hidden; }
  .bv-tile__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
  .bv-tile:hover .bv-tile__media img { transform: scale(1.06); }
  .bv-tile__sku { position: absolute; left: 0; bottom: 0; background: var(--color-ink); color: var(--color-on-rebar); font-family: var(--font-mono); font-size: .75rem; letter-spacing: .06em; padding: .25rem .6rem; }
  .bv-tile__body { display: flex; flex-direction: column; gap: .75rem; padding: 1rem 1rem 1.1rem; flex: 1; transform: translateZ(8px); }
  .bv-tile__cat { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--color-cone-deep); }
  .bv-tile__name { font-size: 1.45rem; line-height: 1; }
  .bv-chips { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; padding: 0; }
  .bv-chips li { font-family: var(--font-mono); font-size: .75rem; background: var(--color-concrete); padding: .2rem .5rem; border-left: 3px solid var(--color-cone); }
  .bv-tile__desc { font-size: .9rem; color: var(--color-steel); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .bv-tile__foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding-top: .85rem; border-top: 1px dashed var(--color-line); }
  .bv-price { font-family: var(--font-mono); font-weight: 500; font-size: 1.25rem; letter-spacing: -.02em; white-space: nowrap; }

  /* filter chips (catalog) */
  .bv-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; background: var(--color-tape); border: var(--bw) solid var(--color-ink); text-decoration: none; font-size: .875rem; font-weight: 600; }
  .bv-chip .bv-icon { width: 14px; height: 14px; }

  /* ---------- quantity ---------- */
  .bv-qty { display: inline-flex; align-items: center; border: var(--bw) solid var(--color-ink); background: var(--color-paper); }
  .bv-qty button { width: 34px; height: 34px; display: grid; place-items: center; }
  .bv-qty button:hover { background: var(--color-tape); }
  .bv-qty span { min-width: 34px; text-align: center; font-family: var(--font-mono); font-weight: 500; border-inline: var(--bw) solid var(--color-ink); line-height: 30px; }

  /* ---------- header cart (Livewire) ---------- */
  .bv-cart { position: static; }
  .bv-cart__toggle { overflow: visible; }
  .bv-cart__badge {
    position: absolute; top: -9px; right: -9px; min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center;
    background: var(--color-cone); color: #fff; border: var(--bw) solid var(--color-ink); font-family: var(--font-mono); font-size: .75rem; font-weight: 500; line-height: 1;
  }
  .bv-cart__badge.is-bump { animation: bv-stamp .5s var(--ease); }
  @keyframes bv-stamp { 0% { transform: scale(2.2) rotate(-12deg); } 60% { transform: scale(.9); } 100% { transform: scale(1); } }
  .bv-cart__panel {
    position: absolute; top: calc(100% + 2px); right: max(1.25rem, calc((100% - 1240px) / 2)); width: min(420px, calc(100vw - 2rem)); max-height: min(78dvh, 640px); overflow: auto;
    background: var(--color-paper); border: var(--bw) solid var(--color-ink); box-shadow: var(--shadow-hard); z-index: 70;
  }
  .bv-cart__head { display: flex; justify-content: space-between; align-items: baseline; padding: 1rem 1.1rem .75rem; border-bottom: var(--bw) solid var(--color-ink); background: var(--color-tape); }
  .bv-cart__head h2 { font-size: 1.6rem; }
  .bv-cart__empty { display: grid; justify-items: start; gap: .75rem; padding: 1.5rem 1.1rem; }
  .bv-cart__empty .bv-icon { width: 42px; height: 42px; }
  .bv-cart__list { list-style: none; padding: 0; }
  .bv-cart__line { display: grid; grid-template-columns: 76px 1fr auto; gap: .8rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--color-line); align-items: start; }
  .bv-cart__line img { width: 76px; height: 57px; object-fit: cover; border: var(--bw) solid var(--color-ink); }
  .bv-cart__name { font-weight: 600; font-size: .9rem; line-height: 1.3; }
  .bv-cart__row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .5rem; }
  .bv-cart__remove { width: 34px; height: 34px; border-width: 1px; }
  .bv-cart__foot { display: grid; gap: .65rem; padding: 1rem 1.1rem 1.2rem; }
  .bv-cart__total { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; text-transform: uppercase; }
  @media (max-width: 1023.98px) {
    .bv-cart__panel { right: 0.75rem; left: .75rem; width: auto; }
  }

  /* ---------- request modal (native dialog) ---------- */
  .bv-modal { margin: auto; padding: 0; border: 0; background: transparent; width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); color: var(--color-ink); overflow: visible; }
  .bv-modal::backdrop { background: var(--scrim); }
  .bv-modal__box { position: relative; background: var(--color-bone); border: var(--bw) solid var(--color-ink); box-shadow: 8px 8px 0 var(--color-ink); padding: 1.75rem; max-height: calc(100dvh - 1.5rem); overflow: auto; }
  .bv-modal__box::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 14px; background: var(--tape); border-bottom: var(--bw) solid var(--color-ink); }
  .bv-modal__box > * { position: relative; }
  .bv-modal__box { padding-top: 2.5rem; }
  .bv-modal__close { position: absolute !important; right: .6rem; top: 1.45rem; width: 40px; height: 40px; }
  .bv-modal__title { font-size: var(--fs-3); margin-bottom: .5rem; padding-right: 3rem; }
  .bv-modal__subject { display: inline-block; margin-bottom: 1.1rem; padding: .25rem .6rem; background: var(--color-cone-soft); border-left: 4px solid var(--color-cone); font-family: var(--font-mono); font-size: .8125rem; }
  .bv-modal__subject:empty { display: none; }
  .bv-modal__done { display: grid; gap: 1rem; justify-items: start; outline: none; }
  .bv-modal__done .bv-icon { width: 54px; height: 54px; color: var(--color-ok); }
  .bv-eyebrow { font-family: var(--font-mono); font-size: var(--fs--1); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--color-cone-deep); }

  /* ---------- toast: title-block strip ---------- */
  .bv-toast {
    position: fixed; left: 50%; bottom: 1.25rem; z-index: 300; transform: translate(-50%, 140%); display: flex; align-items: center; gap: .7rem;
    background: var(--color-ink); color: var(--color-on-rebar); border-left: 10px solid var(--color-tape); padding: .8rem 1.2rem; box-shadow: var(--shadow-hard-sm);
    font-family: var(--font-mono); font-size: .875rem; transition: transform .3s var(--ease); max-width: calc(100vw - 1.5rem);
  }
  .bv-toast.is-on { transform: translate(-50%, 0); }
  .bv-toast .bv-icon { color: var(--color-tape); }

  /* ---------- pagination ---------- */
  .bv-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: 2.5rem; }
  .bv-pages a, .bv-pages span { min-width: 46px; height: 46px; padding: 0 .9rem; display: inline-grid; place-items: center; border: var(--bw) solid var(--color-ink); background: var(--color-paper); text-decoration: none; font-family: var(--font-mono); font-weight: 500; }
  .bv-pages a:hover { background: var(--color-tape); }
  .bv-pages .is-current { background: var(--color-ink); color: var(--color-bone); }
  .bv-pages .is-off { opacity: .4; }

  /* ---------- reveal on scroll ---------- */
  .reveal-ready [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
  .reveal-ready [data-reveal].is-in { opacity: 1; transform: none; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .reveal-ready [data-reveal] { opacity: 1; transform: none; }
  }
}
