/*
Theme Name: Studio K5 v7 (Yellow Edition)
Theme URI: https://www.keigomoriyama.com/
Author: Keigo Moriyama & ChatGPT
Description: Bold yellow theme. YouTube (video left, scrollable list right). Gallery (single theme visible + dropdown filter + lightbox). Mobile puts thumbs below. Clean + stable.
Version: 7.0.0
Text Domain: studio-k5
*/

:root { --yellow:#FFD600; --black:#000; --text:#111; --line:rgba(0,0,0,.14); }
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--yellow);color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Noto Sans JP","Hiragino Kaku Gothic ProN",YuGothic,Meiryo,sans-serif;
}
a{color:var(--text);text-decoration:none}
.container{max-width:1200px;margin:0 auto;padding:16px 16px}

/* Header */
.site-header{position:sticky;top:0;background:var(--yellow);border-bottom:2px solid var(--black);z-index:20}
.site-header .inner{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:12px 16px;max-width:1200px;margin:0 auto}
.site-logo img{height:44px;width:auto;display:block}
.site-nav ul{list-style:none;margin:0;padding:0;display:flex;gap:14px;font-weight:800}
.site-nav a{padding:8px 10px;border:2px solid var(--black);border-radius:10px}

/* Section titles */
.k5-sec-title{font-weight:900;margin:16px 0 12px}

/* YouTube layout */
.k5-yt .k5-yt-wrap{display:grid;grid-template-columns:58% 1fr;gap:18px}
.k5-yt .k5-yt-main{border:2px solid var(--black);border-radius:16px;overflow:hidden;background:#fff;height:420px;box-shadow:4px 4px 0 var(--black)}
.k5-yt .k5-yt-main iframe{width:100%;height:100%;border:0;display:block}
.k5-yt .k5-yt-list{border:2px solid var(--black);border-radius:16px;background:#fff;padding:10px;display:flex;flex-direction:column;gap:10px;max-height:420px;overflow:auto}
.k5-yt .k5-yt-item{display:grid;grid-template-columns:120px 1fr;gap:10px;align-items:center;border:2px solid var(--black);border-radius:12px;background:#fff;cursor:pointer}
.k5-yt .k5-yt-thumb{width:120px;aspect-ratio:16/9;object-fit:cover;display:block}
.k5-yt .k5-yt-title{font-weight:700;line-height:1.2;padding-right:8px}

/* Gallery base */
#gallery.k5g-home .k5g-top{display:flex;align-items:center;gap:12px;margin-bottom:12px}
#gallery.k5g-home .k5g-wrap{display:none;gap:18px;align-items:flex-start;margin:18px 0}
#gallery.k5g-home .k5g-view{flex:1 1 auto;border:2px solid var(--black);border-radius:16px;overflow:hidden;background:#fff;display:flex;align-items:center;justify-content:center;height:420px;box-shadow:4px 4px 0 var(--black)}
#gallery.k5g-home .k5g-view img{max-width:100%;max-height:100%;object-fit:contain;display:block}
#gallery.k5g-home .k5g-thumbs{width:240px;border:2px solid var(--black);border-radius:16px;background:#fff;padding:10px;max-height:420px;overflow:auto}
#gallery.k5g-home .k5g-thumbs a{display:block;height:80px;margin-bottom:10px;border:2px solid var(--black);border-radius:12px;overflow:hidden;background:#fff}
#gallery.k5g-home .k5g-thumbs img{width:100%;height:100%;object-fit:cover;display:block}

/* Lightbox */
#k5Lightbox{position:fixed;inset:0;background:rgba(0,0,0,.92);display:none;align-items:center;justify-content:center;z-index:9999}
#k5Lightbox.open{display:flex}
#k5Lightbox .k5lb-img{max-width:92vw;max-height:80vh;object-fit:contain;display:block;background:#111;box-shadow:0 0 0 3px #000, 0 0 1px 6px rgba(0,0,0,.35)}
#k5Lightbox .k5lb-cap{position:fixed;left:0;right:0;bottom:20px;text-align:center;color:#fff;font-weight:700;padding:6px 12px;text-shadow:0 1px 2px rgba(0,0,0,.6)}
#k5Lightbox .k5lb-close,#k5Lightbox .k5lb-prev,#k5Lightbox .k5lb-next{position:fixed;top:16px;width:44px;height:44px;border-radius:50%;border:2px solid #fff;background:transparent;color:#fff;font-size:28px;display:flex;align-items:center;justify-content:center;cursor:pointer}
#k5Lightbox .k5lb-close{right:16px}
#k5Lightbox .k5lb-prev{left:16px;top:50%;transform:translateY(-50%)}
#k5Lightbox .k5lb-next{right:16px;top:50%;transform:translateY(-50%)}

/* Footer */
.site-footer{padding:36px 16px;border-top:2px solid var(--black);text-align:center;font-weight:700}

/* Mobile */
@media(max-width:980px){
  .k5-yt .k5-yt-wrap{grid-template-columns:1fr}
  .k5-yt .k5-yt-main{height:auto}
  .k5-yt .k5-yt-list{max-height:320px}

  #gallery.k5g-home .k5g-wrap{flex-direction:column}
  #gallery.k5g-home .k5g-view{width:100%;height:auto;max-height:none;margin-bottom:12px}
  #gallery.k5g-home .k5g-view img{width:100%;height:auto;object-fit:contain}
  #gallery.k5g-home .k5g-thumbs{width:100%;max-height:120px;display:flex;flex-direction:row;overflow-x:auto;overflow-y:hidden;gap:10px}
  #gallery.k5g-home .k5g-thumbs a{width:100px;height:72px;flex:0 0 auto;margin:0}
}
/* ======= K5 Unified Gallery ======= */
#gallery.k5g-home { padding: 40px 24px; }
#gallery .k5g-sec-title { font-weight:800; margin:0 0 16px; }

#gallery .k5g-bar {
  margin: 0 0 16px;
  display:flex; align-items:center; gap:10px;
}
#gallery .k5g-lab { font-weight:700; }
#gallery .k5g-select {
  padding:8px 12px; border:2px solid #000; border-radius:12px; font-weight:700;
  background:#eee;
}

#gallery .k5g-view {
  border:2px solid #000; border-radius:18px; background:#fff;
  display:flex; align-items:center; justify-content:center;
  padding:8px; margin-bottom:14px;
}
#gallery #k5g-main { max-width:100%; max-height:70vh; object-fit:contain; display:block; }

#gallery .k5g-thumbs {
  display:flex; gap:12px; overflow-x:auto; padding:10px; border:2px solid #000;
  border-radius:16px; background:#fff;
}
#gallery .k5g-thumb {
  flex:0 0 auto; width:120px; height:90px; border:2px solid #000;
  border-radius:14px; overflow:hidden; display:block; background:#fff;
}
#gallery .k5g-thumb img { width:100%; height:100%; object-fit:cover; display:block; }

/* mobile tune */
@media (max-width: 980px){
  #gallery #k5g-main { max-height:60vh; }
  #gallery .k5g-thumb { width:100px; height:75px; }
}
/* === Studio K5 – Unified Gallery (B-size tuning) === */

/* section spacing */
#gallery.k5g-home { padding: 24px; }

/* bar (label + select) just under title */
.k5g-bar { display:flex; align-items:center; gap:12px; margin:8px 0 16px; }
.k5g-lab { font-weight:700; }
.k5g-select {
  padding:8px 12px; border:2px solid #000; border-radius:10px;
  font-weight:700; background:#fff;
}

/* big viewer */
.k5g-view {
  border:2px solid #000; border-radius:18px; background:#fff;
  overflow:hidden; display:flex; align-items:center; justify-content:center;
  margin:0 0 14px 0;
}
.k5g-view img { max-width:100%; height:auto; display:block; }

/* thumbs strip below (horizontal scroll) */
.k5g-thumbs {
  display:flex; gap:12px; padding:10px; border:2px solid #000; border-radius:16px;
  background:#fff; overflow-x:auto; overflow-y:hidden;
}
.k5g-thumbs .k5g-thumb {
  display:inline-block; flex:0 0 auto;
  width:140px; height:94px; border:2px solid #000; border-radius:14px; overflow:hidden;
  background:#fff;
}
.k5g-thumbs .k5g-thumb img {
  width:100%; height:100%; object-fit:cover; display:block;
}

/* Lightbox */
#k5Lightbox{position:fixed;inset:0;background:rgba(0,0,0,.92);display:none;align-items:center;justify-content:center;z-index:9999}
#k5Lightbox.open{display:flex}
#k5Lightbox .k5lb-img{max-width:92vw;max-height:80vh;display:block;object-fit:contain}
#k5Lightbox .k5lb-close,#k5Lightbox .k5lb-prev,#k5Lightbox .k5lb-next{
  position:fixed;top:16px;width:44px;height:44px;border-radius:50%;border:2px solid #fff;
  background:transparent;color:#fff;font-size:28px;display:flex;align-items:center;justify-content:center
}
#k5Lightbox .k5lb-close{right:16px}
#k5Lightbox .k5lb-prev{left:16px;top:50%;transform:translateY(-50%)}
#k5Lightbox .k5lb-next{right:16px;top:50%;transform:translateY(-50%)}

/* Mobile tweaks */
@media (max-width:980px){
  .k5g-view{ margin-bottom:12px; }
  .k5g-thumbs .k5g-thumb{ width:120px; height:82px; }
  #k5Lightbox .k5lb-prev,#k5Lightbox .k5lb-next{ width:56px;height:56px;font-size:34px; }
}
/* Kill any accidental second gallery section after the first one */
section#gallery.k5g-home ~ section#gallery,
section#gallery.k5g-home ~ .k5g-home {
  display: none !important;
}
/* === K5 Gallery: horizontal thumbnails (desktop) === */
:root { --k5g-max: 1280px; } /* tweak if you want wider/narrower */

@media (min-width: 900px) {
  .k5g-home .k5g-view {
    max-width: var(--k5g-max) !important;
    margin: 0 auto !important;
  }

  /* make the thumbs a row, full width under the main image */
  .k5g-home .k5g-thumbs {
    max-width: var(--k5g-max) !important;
    width: 100% !important;
    margin: 16px auto 0 !important;

    display: flex !important;
    flex-direction: row !important;   /* ← force horizontal */
    flex-wrap: wrap !important;
    gap: 12px !important;
    justify-content: flex-start !important;

    padding: 0 4px;
    border-radius: 18px;
    background: transparent;          /* no white vertical panel */
  }

  .k5g-home .k5g-thumb {
    width: 160px;                     /* adjust to taste */
    aspect-ratio: 4 / 3;
    border: 2px solid #000;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
  }

  .k5g-home .k5g-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
}

/* mobile unchanged */
@media (max-width: 899.98px) {
  .k5g-home .k5g-view,
  .k5g-home .k5g-thumbs {
    max-width: 100% !important;
    margin-left: auto;
    margin-right: auto;
  }
}
