.modal-overlay{
  position: fixed; inset: 0;
  display:flex; align-items:center; justify-content:center;
  background: rgba(243,240,233,0.001);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  z-index: 100;
  padding: 24px;
}
.modal-overlay.open{
  opacity: 1;
  pointer-events: auto;
}
.modal{
  position: relative;
  width: min(720px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1.5px solid var(--ink);
  border-radius: 32px;
  padding: 48px;
  transform: scale(.94);
  transition: transform .35s ease;
  font-family: 'Cascadia Code', monospace;
}
.modal-overlay.open .modal{
  transform: scale(1);
}
.modal-close{
  position: absolute; top: 20px; right: 20px;
  z-index: 2; /* above the product modal's positioned header, which paints later in the DOM */
  width: 34px; height: 34px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px; line-height:1;
  cursor: pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .1s ease, color .1s ease;
}
.modal-close:active,
.modal-close.pressed{
  background: var(--ink);
  color: var(--bg);
  transition: none; /* invert instantly on press, so even a quick tap shows it */
}

.modal h2{
  font-family:'Cascadia Code', monospace;
  font-size: 22px;
  margin: 0 0 20px;
}
.modal p{
  font-size: 14px;
  line-height: 1.7;
  color: #444440;
}
.about-formula{
  color: var(--ink) !important;
  letter-spacing: .02em;
}

/* product modal — header/accordion body/footer, fixed height driven by the
   viewport (like the original modal before this rework), so it doesn't
   reflow with window size while open. */
.modal.is-product{
  display: flex;
  flex-direction: column;
  height: min(86vh, 760px);
  max-height: none;
  padding: 0;
  overflow: hidden;
}
/* #modal-content is a plain block <div> (js/modals.js only ever sets its
   innerHTML) — without this, it doesn't forward the flex column down to
   the header/body/footer structure openProductModal renders inside it. */
.modal.is-product #modal-content{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pmodal-header{
  position: relative;
  z-index: 1; /* keeps the share button's "copied" tooltip above the gallery below */
  flex: 0 0 auto;
  display: flex; align-items: center;
  padding: 20px 140px 16px 28px; /* room for the share + close buttons on the right */
  border-bottom: 1px solid rgba(28,28,26,.08);
}
.pmodal-header h2{
  margin: 0; font-size: 20px; line-height: 1.2;
  display: flex; align-items: center; gap: 10px;
}
/* Sits just left of the shared #modal-close button (top:20px; right:20px,
   34px wide) — same size/shape, same press-to-invert behavior. */
.pmodal-share{
  position: absolute; top: 20px; right: 64px;
  height: 34px; padding: 0 12px;
  font-family: 'Cascadia Code', monospace;
  font-size: 12px; letter-spacing: .04em;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s ease, color .1s ease;
}
.pmodal-share:hover{
  background: var(--teal);
}
.pmodal-share:active{
  background: var(--ink);
  color: var(--bg);
}
.pmodal-share-feedback{
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--ink); color: var(--bg);
  font-family: 'Cascadia Code', monospace;
  font-size: 11px; letter-spacing: .04em;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.pmodal-share.copied .pmodal-share-feedback{ opacity: 1; }
.pmodal-body{
  flex: 1 1 auto;
  min-height: 0;
  display: flex; flex-direction: column;
  padding: 0 28px;
  overflow: hidden;
}
.pmodal-footer{
  flex: 0 0 auto;
  display:flex; align-items:center; justify-content:space-between;
  padding: 18px 28px;
  border-top: 1px solid rgba(28,28,26,.08);
}

.pm-section{
  flex: 0 0 auto; /* images stays this way always — see js/modals.js */
  display: flex; flex-direction: column;
  min-height: 0;
}
/* Only description/technical-details grow to fill the space the compressed
   square frees up; images itself never stretches (js/modals.js sizes its
   square explicitly by width instead). */
.pm-section.expanded:not([data-section="images"]){
  flex: 1 1 auto;
}
.pm-section.expanded:not([data-section="images"]) .pm-section-content{
  flex: 1 1 auto;
  min-height: 0;
}
.pm-section-toggle{
  all: unset;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px;
  font-family: 'Cascadia Code', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #77756c;
  cursor: pointer;
  border-top: 1px solid rgba(28,28,26,.08);
}
.pm-section:first-child .pm-section-toggle{ border-top: none; }
.pm-section-toggle::after{ content: '+'; font-size: 15px; line-height:1; color: var(--ink); }
.pm-section.expanded .pm-section-toggle::after{ content: '\2013'; } /* – */

.pm-section-content{
  min-height: 0;
  overflow-y: auto; /* safety net for unusually long text; the modal itself never scrolls */
}
.pm-section[data-section="images"] .pm-section-content{ overflow: visible; padding: 14px 0 12px; }
.pm-section:not(.expanded):not([data-section="images"]) .pm-section-content{ display: none; }
.pm-section-content p{ margin: 4px 0 14px; }

/* Square — js/modals.js sets this box's *width* explicitly in px (clamped to
   both the column's width and the body's available height), height always
   follows via aspect-ratio, so the photo shrinks proportionally when another
   section opens rather than being cropped inside a short, full-width
   rectangle. */
.gallery-wrap{
  position: relative;
  cursor: pointer; /* clicking the compressed square re-expands it (js/modals.js) */
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  transition: width .3s ease;
  touch-action: pan-y; /* a horizontal swipe pages the photo (js/modals.js), vertical still scrolls */
}
.gallery-main{
  width: 100%; height: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: var(--card-bg);
}
.gallery-main img, .gallery-main .art{ width:100%; height:100%; object-fit:contain; }
.gallery-main video{ width:100%; height:100%; object-fit:cover; display:block; }
.gallery-arrow{
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: rgba(243,240,233,.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display:flex; align-items:center; justify-content:center;
  font-size: 18px; line-height:1;
  transition: opacity .2s ease;
}
.gallery-arrow.prev{ left: 12px; }
.gallery-arrow.next{ right: 12px; }
.gallery-wrap.compact .gallery-arrow{ opacity: 0; pointer-events: none; }
@media (pointer: coarse){
  .gallery-arrow{ width: 42px; height: 42px; }
}

.tech-list{ margin: 4px 0 14px; }
.tech-row{
  display:flex; justify-content:space-between; gap: 20px;
  padding: 8px 0;
  border-top: 1px solid rgba(28,28,26,.06);
  font-size: 13px;
}
.tech-row:first-child{ border-top: none; }
.tech-row dt{ color: #77756c; text-transform: uppercase; letter-spacing: .05em; font-size: 11px; align-self:center; }
.tech-row dd{ margin: 0; text-align: right; }

.buy-row, .pmodal-footer{ }
.price{ font-family:'Cascadia Code', monospace; font-size: 20px; }
.buy-btn{
  font-family:'Cascadia Code', monospace;
  font-size: 14px;
  padding: 12px 28px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  transition: opacity .2s ease;
}
.buy-btn:hover{ opacity:.8; }

/* contact modal */
.contact-list{ display:flex; flex-direction:column; gap: 10px; margin: 20px 0 28px; }
.contact-list a{
  color: var(--ink);
  text-decoration:none;
  font-size: 14px;
  border-bottom: 1px solid transparent;
}
.contact-list a:hover{ border-bottom-color: var(--ink); }

.contact-form{ display:flex; flex-direction:column; gap: 12px; }
.contact-form input, .contact-form textarea{
  font-family:'Cascadia Code', monospace;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}
.contact-form button{
  align-self: flex-start;
  font-family:'Cascadia Code', monospace;
  font-size: 14px;
  padding: 12px 28px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}

@media (max-width: 820px){
  .modal{ padding: 32px 24px; border-radius: 24px; }
  .modal.is-product{ height: 88vh; }
  .pmodal-header{ padding: 16px 104px 12px 22px; }
  .pmodal-body{ padding: 0 22px; }
  .pmodal-footer{ padding: 14px 22px; }
}
