/* Codex42 gallery v1: only what gallery.html has and no other page does
   (tab switch, screenshot cards, the "Also built" rows, lightbox).
   Loads after ui-v1.css and reuses its components and the --c42-* tokens.
   Versioned filename: rename (gallery-v2.css) when editing after a deploy, the CDN caches assets for days. */

/* keeps the page from shifting sideways when the lightbox locks scrolling */
html{scrollbar-gutter:stable}
html.is-zoomed{overflow:hidden}

/* ---------- tab switch (hidden without JS: both panels then show, stacked) ---------- */
.gbar{display:none}
/* the bar sticks under the nav; once stuck it takes the nav's own glass so the two read as one header */
html.js .gbar{display:block;position:sticky;top:var(--c42-nav-h);z-index:40;margin-top:8px;padding:10px 0;border-bottom:1px solid transparent;
  transition:background .35s var(--c42-ease),border-color .35s var(--c42-ease)}
html.js .gbar.is-stuck{background:rgba(6,9,12,.86);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-bottom-color:var(--c42-line)}
.gtabs{position:relative;display:inline-grid;grid-template-columns:repeat(2,minmax(0,1fr));padding:5px;border-radius:999px;
  background:rgba(255,255,255,.04);border:1px solid var(--c42-line-2)}
.gtabs::before{content:"";position:absolute;top:5px;bottom:5px;left:5px;width:calc(50% - 5px);border-radius:999px;background:var(--c42-accent);
  box-shadow:0 10px 26px -12px rgba(67,224,138,.9);transition:transform .45s var(--c42-ease)}
.gtabs[data-on="apps"]::before{transform:translateX(100%)}
.gtab{position:relative;z-index:1;min-height:44px;padding:0 28px;border:0;border-radius:999px;background:none;cursor:pointer;
  font:600 15.5px/1 var(--c42-sans);color:var(--c42-text-2);white-space:nowrap;transition:color .25s}
.gtab:hover{color:var(--c42-text)}
.gtab[aria-selected="true"]{color:#04140b}
.gtab:focus-visible{outline-offset:4px;border-radius:999px}
.gtab-n{margin-left:5px;font:500 12.5px/1 var(--c42-mono);opacity:.72}

/* ---------- panels ---------- */
.gpanel{padding:clamp(24px,3vw,36px) 0 clamp(72px,9vw,120px)}
.gpanel[hidden]{display:none}
.gpanel + .gpanel{border-top:1px solid var(--c42-line);padding-top:clamp(56px,7vw,88px)}
.gpanel-h{font-size:clamp(28px,3.7vw,48px);margin-bottom:clamp(20px,2.6vw,32px)}
.glead{margin-bottom:clamp(20px,2.6vw,30px)}
/* with JS the tab names the panel, so its heading is kept for screen readers only */
html.js .gpanel-h{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
html.js .gpanel + .gpanel{border-top:0;padding-top:clamp(24px,3vw,36px)}
/* a deep link (/gallery#apps) opens the right tab but keeps the page head in view:
   the margin is taller than the head, so the browser's jump to the panel stops at the top */
html.js .gpanel{scroll-margin-top:680px}
/* before the script runs, a deep link to Apps already hides the other panel (no flash, no wrong jump) */
html.js:not(.gal-on):has(#apps:target) #websites{display:none}

/* ---------- cards: two columns, the picture first, then a few words ---------- */
.cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(40px,4.6vw,60px) clamp(24px,3vw,40px)}
.card{display:flex;flex-direction:column;min-width:0}
.card-body{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:20px 4px 0}
.card-meta{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin-bottom:4px}
.plat{font:500 12px/1.3 var(--c42-mono);color:var(--c42-faint)}
.card-body h3{font-size:clamp(21px,2vw,25px)}
.card-body p{color:var(--c42-text-2);font-size:15.5px;line-height:1.55}
.card-body .link-arrow{margin-top:4px}

/* ---------- stage: the dark panel the screenshots sit on. One ratio, so every card is the same height ---------- */
.stage{--bar:33px;position:relative;aspect-ratio:4/3;border-radius:20px;border:1px solid var(--c42-line);background:radial-gradient(120% 90% at 50% 0%,#12201c,#0a1114 70%);transition:border-color .35s}
.card:hover .stage{border-color:rgba(67,224,138,.32)}
.stage .frame-browser,.stage .frame-phone{transition:transform .6s var(--c42-ease)}

/* a screenshot is a button: it opens the lightbox */
.shot{position:relative;display:block;width:100%;margin:0;padding:0;border:0;background:none;color:inherit;font:inherit;text-align:left;cursor:default}
.shot img{width:100%;height:auto}
.shot:focus-visible{outline:2px solid var(--c42-accent);outline-offset:-2px;border-radius:0}
html.gal-zoom .shot{cursor:zoom-in}
html.gal-zoom .shot::after{content:"";position:absolute;right:10px;top:10px;width:30px;height:30px;border-radius:50%;border:1px solid var(--c42-line-2);opacity:0;transition:opacity .2s;
  background:linear-gradient(#eef0f5,#eef0f5) center/12px 2px no-repeat,linear-gradient(#eef0f5,#eef0f5) center/2px 12px no-repeat,rgba(6,9,12,.82)}
html.gal-zoom .shot:focus-visible::after{opacity:1}

/* browser window with a phone over its bottom-right corner */
.stage--scene{aspect-ratio:1100/614;overflow:hidden}
.stage--scene .shot,.stage--scene .shot img{width:100%;height:100%}
.stage--scene .shot img{object-fit:cover;transition:transform .9s var(--c42-ease)}
.card:hover .stage--scene .shot img{transform:scale(1.035)}
.stage--solo{display:flex;align-items:center;padding:0 7%}
.stage--solo .frame-browser{width:100%}
.stage--duo{display:flex;align-items:center;padding:0 11% 2.5% 7%}
.stage--duo .frame-browser{width:100%}
.stage--duo .frame-phone{position:absolute;right:4.5%;bottom:6%;width:20%;border-width:clamp(3px,.4vw,4px);border-radius:clamp(10px,1.5vw,16px)}
html.gal-zoom .stage--duo .frame-phone .shot::after{display:none}

/* phones side by side, stepped (the widths follow each app's screenshot shape so all three sets are the same height) */
.stage--phones{display:flex;justify-content:center;align-items:center;gap:4%}
.stage--phones .frame-phone{flex:0 0 auto;width:25%;border-width:clamp(3px,.4vw,5px);border-radius:clamp(11px,1.7vw,20px)}
.stage--phones .frame-phone:nth-child(2){margin-top:6%}
.stage--phones.is-2 .frame-phone{width:29%}
.stage--phones.is-1 .frame-phone{width:32%}

/* two windows, the second over the corner of the first (--bar is the height a window adds around its picture) */
.stage--pair{display:flex;flex-direction:column;justify-content:center;padding:0 7%}
.stage--pair .frame-browser:first-child{width:80%}
.stage--pair .frame-browser + .frame-browser{position:relative;width:52%;margin:-17% 0 0 auto;box-shadow:0 30px 70px -22px #000}
.stage--pair.is-tall .frame-browser:first-child{width:65%}
.stage--pair.is-tall .frame-browser + .frame-browser{width:53%;margin-top:calc(-43% - var(--bar))}

/* one main window with two smaller ones under it (the flex factors are the pictures' aspect ratios, so the two end level) */
.stage--trio{display:flex;flex-wrap:wrap;align-content:center;gap:clamp(8px,1.4vw,14px);padding:0 12%}
.stage--trio .frame-browser{flex:1 1 0;min-width:0}
.stage--trio .frame-browser:first-child{flex:1 1 100%}
.stage--trio .frame-browser:nth-child(2){flex-grow:1.63}
.stage--trio .frame-browser:nth-child(3){flex-grow:1.742}
.stage--trio .frame-browser + .frame-browser{border-radius:10px}

/* ---------- "Also built": the apps with no screenshot, as compact rows ---------- */
.also{margin-top:clamp(56px,7vw,88px)}
.also > h3{font-size:clamp(22px,2.2vw,28px);margin-bottom:20px}
.also-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px clamp(24px,3vw,40px)}
.also-row{display:grid;grid-template-columns:40px minmax(0,1fr);gap:6px 16px;align-content:start;padding:18px 20px;border-radius:16px;background:var(--c42-panel);border:1px solid var(--c42-line)}
.also-row img{grid-row:1 / span 2;width:40px;height:40px;border-radius:23.5%}
.also-head{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;min-height:24px}
.also-head h4{margin:0;font:600 17px/1.3 var(--c42-display);letter-spacing:-.01em;color:var(--c42-text)}
.also-row p{grid-column:2;color:var(--c42-text-2);font-size:15px;line-height:1.5}
.also-row .link-arrow{font-size:14.5px}

/* ---------- lightbox ---------- */
.lightbox{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:var(--c42-text);overflow:hidden;cursor:zoom-out}
.lightbox[open]{display:grid;place-items:center}
.lightbox::backdrop{background:rgba(3,5,7,.9);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}
.lightbox-fig{display:grid;justify-items:center;gap:14px;width:100%;margin:0;padding:72px 20px 24px;animation:lb-in .35s var(--c42-ease)}
.lightbox-fig img{width:auto;height:auto;max-width:min(1280px,100%);max-height:calc(100vh - 150px);max-height:calc(100dvh - 150px);
  border-radius:12px;border:1px solid var(--c42-line-2);background:#0c1317;box-shadow:0 40px 90px -30px #000;cursor:default}
.lightbox-fig figcaption{max-width:60ch;text-align:center;font:400 13px/1.5 var(--c42-mono);color:var(--c42-text-2)}
.lightbox-close{position:absolute;top:16px;right:16px;z-index:1}
@keyframes lb-in{from{opacity:0;transform:scale(.97)}}

/* ---------- responsive ---------- */
@media (hover:hover){
  html.gal-zoom .shot:hover::after{opacity:1}
  .card:hover .stage--duo .frame-browser{transform:translateY(-3px)}
  .card:hover .stage--duo .frame-phone{transform:translateY(-8px)}
}
@media (max-width:760px){
  .cards,.also-list{grid-template-columns:minmax(0,1fr)}
  .stage{border-radius:16px}
}
@media (max-width:680px){
  .cta .actions .btn-ghost{flex:1 1 28%;padding:0 10px}
}
@media (max-width:520px){
  html.js .gbar{padding:8px 0}
  .gtabs{display:grid;padding:4px}
  .gtabs::before{top:4px;bottom:4px;left:4px;width:calc(50% - 4px)}
  .gtab{min-height:42px;padding:0 12px}
  /* slimmer window bars, so the stacked windows still fit the stage */
  .stage{--bar:25px}
  .stage .frame-bar{height:22px;padding:0 9px;gap:4px;font-size:10px}
  .stage .frame-bar i{width:6px;height:6px}
  .also-row{padding:16px}
  .lightbox-fig{padding:68px 12px 20px}
}
@media (prefers-reduced-motion:reduce){
  html.js .gbar,.gtabs::before,.gtab,.stage,.stage .frame-browser,.stage .frame-phone,.shot::after{transition:none}
  .card:hover .stage--duo .frame-browser,.card:hover .stage--duo .frame-phone{transform:none}
  .lightbox-fig{animation:none}
}
