/* ============================================================
   MIO KOSAKA — Portfolio v2
   Folder-tab drawer, fixed arrows, viewport-fitted hero.
   ============================================================ */

:root {
  --ink: #111111;
  --paper: #ffffff;
  --hairline: 1px solid var(--ink);
  --pad: clamp(16px, 2.5vw, 40px);

  /* ===== 調整ノブ（デザイン微調整はまずここ） ===== */
  --collapsed-h: 96px;        /* 下部パネル（縮小時）の高さ */
  --head-reserve: 100px;      /* タイトル行の予約高さ。減らすと本文が上がり、ヒーローが伸びる */
  --detail-top: clamp(20px, 3vw, 44px);  /* 本文の始まりの高さ（タイトル行との間隔） */
  --text-width: 350px;        /* 本文テキストの最大幅 */
  /* ヒーローをさらに伸ばす量は js/main.js 冒頭の HERO_EXTRA */
  /* ============================================== */

  --panel-color: #ffffff;        /* set per-tab via JS */
  --hero-h: 60vh;                /* set by JS to fit viewport */
  --font: "Neue Haas Grotesk Display Pro", "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic ProN", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: baseline;
  gap: clamp(16px, 3vw, 48px);
  padding: clamp(14px, 2vw, 28px) var(--pad);
}
.site-name {
  font-size: clamp(24px, 3vw, 44px);
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.site-tagline { font-size: clamp(12px, 1.1vw, 16px); }

/* ---------- Fixed arrows ---------- */
.arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  color: var(--ink);
  padding: 14px 8px;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(2px);
  transition: background 0.15s ease;
}
.arrow:hover { background: rgba(255, 255, 255, 0.95); }
.arrow:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.arrow-prev { left: clamp(4px, 1vw, 18px); }
.arrow-next { right: clamp(4px, 1vw, 18px); }
body.expanded .arrow { opacity: 0; pointer-events: none; }

/* ---------- Hero: crop flexes, image ratio preserved via cover ---------- */
.hero { padding: 0 clamp(52px, 6vw, 110px); }
.hero-frame { width: 100%; max-width: 1700px; margin: 0 auto; }
.hero-image {
  width: 100%;
  height: var(--hero-h);
  min-height: 220px;
  object-fit: cover;   /* aspect of source preserved; crop adapts */
  background: var(--paper);
}

/* ---------- Project head ---------- */
.project-head {
  display: grid;
  grid-template-columns: clamp(320px, 38vw, 360px) 1fr; /* col 1 fixed → deliverables always start at the same x */
  align-items: start;
  gap: clamp(14px, 2vw, 32px);
  height: var(--head-reserve); /* fixed → hero height identical across projects */
  padding: 0px clamp(52px, 6vw, 110px) 0;
}
.project-title-box {
  justify-self: start; /* box grows with the title, but never pushes the tags */
  border: var(--hairline);
  padding: 6px 18px;
  font-size: clamp(18px, 1.8vw, 28px);
  font-weight: 400;
  background: var(--paper);
}
.project-tags {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* margin-top set by JS so the first item centers on the title box */
}
.project-tags li {
  font-size: clamp(12px, 1vw, 16px);
  display: flex;
  align-items: center;
  gap: 9px;
}
.project-tags li::before {
  content: "";
  width: 10px; height: 10px;
  border: var(--hairline);
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- Detail ---------- */
/* --- Detail: one 3-column grid across the full content width.
       Column 1's left edge = the description text's left edge. --- */
.project-detail {
  padding: var(--detail-top) clamp(52px, 6vw, 110px) 60px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2.5vw, 40px);
  align-items: start;
}
.project-description {
  grid-column: 1 / 3;      /* text lives in columns 1–2 */
  grid-row: 1;
  max-width: var(--text-width);
  font-size: 15px;
  line-height: 1.55;
}
.project-description p + p { margin-top: 1em; }

/* gallery children join the parent grid directly */
.project-gallery { display: contents; }

/* the first image always sits beside the text: 2 columns, right-aligned */
.project-gallery .gallery-item:first-child {
  grid-column: 2 / 4 !important;
  grid-row: 1;
}

.gallery-item { margin: 0; }
.gallery-item img { width: 100%; background: var(--paper); }

.gallery-item.size-large  { grid-column: 1 / -1; }

.gallery-item.size-medium              { grid-column: 1 / 3; }
.gallery-item.size-medium.align-right  { grid-column: 2 / 4; }

.gallery-item.size-small               { grid-column: 1 / 2; }
.gallery-item.size-small.align-center  { grid-column: 2 / 3; }
.gallery-item.size-small.align-right   { grid-column: 3 / 4; }

/* ============================================================
   Folder-tab drawer
   ============================================================ */
.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
}

/* --- Tab row: manila folder tabs --- */
.tab-row {
  display: flex;
  align-items: flex-end;
  position: relative;
  padding: 0 0;
  background: transparent;
  pointer-events: none; /* the empty gap is click-through */
}
.tab { pointer-events: auto; }
/* the shelf line the tabs sit on */
.tab-row::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border-bottom: var(--hairline);
  z-index: 0;
}

.tab {
  position: relative;
  z-index: 1;
  font-size: 14px;
  padding: 7px 26px;
  border: var(--hairline);
  border-bottom: none;
  background: var(--tab-color, var(--paper));
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* adjacent tabs share one border line instead of stacking two 1px lines */
.tab + .tab { margin-left: -1px; }
.tab:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }

/* inactive tabs: shelf line passes underneath them */
.tab { box-shadow: inset 0 -1px 0 var(--ink); }

/* active tab merges with the panel — the manila folder effect */
.tab.active {
  background: var(--panel-color);
  box-shadow: none;
  z-index: 2; /* its border sits above neighbours' */
}

/* See All tab is always part of the folder */
.tab-toggle {
  background: var(--panel-color);
  box-shadow: none;
  z-index: 2;
  margin-left: -1px;  /* left border sits off-screen */
}
.tab[data-tab="contact"] { margin-right: -1px; } /* right border off-screen */
.tab-spacer { flex: 1; }
.tab[data-tab="contact"] { margin-right: 0; }

.chev { display: inline-flex; transition: transform 0.35s ease; }
body.expanded .chev { transform: rotate(180deg); }

/* --- Panel --- */
.panel {
  position: relative;
  background: var(--panel-color);
  border-top: none;
  overflow: hidden;
  height: var(--collapsed-h); /* JS overrides for expand animation */
  transition: height 0.45s cubic-bezier(0.22, 0.8, 0.3, 1);
}

body.expanded { overflow: hidden; } /* page behind stays put while a panel is open */

.panel-content { height: 100%; }
.expanded-only { display: none; height: 100%; }
body.expanded .expanded-only { display: block; }
body.expanded .collapsed-only { display: none; }

.panel-scroll {
  overflow-y: auto;
  overscroll-behavior: contain; /* wheel stays inside the panel */
  height: 100%;
  padding: clamp(20px, 3vw, 40px) var(--pad) 60px;
}

.panel-text {
  max-width: 680px;
  font-size: clamp(15px, 1.2vw, 17px);
  line-height: 1.6;
  white-space: pre-line;
}
.panel-text a { color: var(--ink); }
.collapsed-only.panel-text {
  padding: 14px var(--pad);
  overflow: hidden; /* fixed-height drawer: keep short texts short in the CMS */
}

/* --- Thumbnail strip (Projects collapsed) --- */
.thumb-strip {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 11px var(--pad);
  scrollbar-width: thin;
}
.thumb {
  flex: 0 0 auto;
  width: calc(var(--collapsed-h) - 22px);
  height: calc(var(--collapsed-h) - 22px);
  padding: 0;
  border: 1px solid transparent;
}
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  background: var(--paper);
}
.thumb.active { border-color: var(--ink); padding: 3px; }
.thumb:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* --- See All grid (Projects expanded) — unchanged, as requested --- */
.see-all-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px;
}
.see-all-item { text-align: left; }
.see-all-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--paper);
  margin-bottom: 10px;
}
.see-all-item .t { font-size: 15px; }
.see-all-item .c { font-size: 12px; opacity: 0.6; margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  :root { --collapsed-h: 80px; --head-reserve: 160px; }
  .site-header { flex-direction: column; gap: 6px; }
  .project-head { grid-template-columns: 1fr; }

  /* hero goes full window width; arrows sit on top of it in white */
  .hero { padding-left: 0; padding-right: 0; }
  .hero-frame { max-width: none; }
  .arrow {
    color: #ffffff;
    background: none;
    backdrop-filter: none;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.45)); /* stays legible on light images */
    padding: 12px 6px;
  }
  .arrow-prev { left: 4px; }
  .arrow-next { right: 4px; }

  .project-head { padding-left: var(--pad); padding-right: var(--pad); }
  .project-detail { grid-template-columns: 1fr; padding-left: var(--pad); padding-right: var(--pad); }
  .project-description { grid-column: 1 / -1; }
  .gallery-item.size-large,
  .gallery-item.size-medium,
  .gallery-item.size-small,
  .project-gallery .gallery-item:first-child { grid-column: 1 / -1 !important; grid-row: auto; } /* stack everything on phones */
  .tab { padding: 6px 14px; font-size: 13px; }
}

/* ---------- Loading screen ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}
.loader.done {
  opacity: 0;
  pointer-events: none;
}
.loader-text {
  font-size: clamp(24px, 3vw, 44px);
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ---------- About photo ---------- */
.about-photo {
  float: right;
  width: clamp(160px, 25vw, 280px);
  margin: 0 0 20px 28px;
  object-fit: cover;
}
@media (max-width: 860px) {
  .about-photo {
    float: none;
    width: 100%;
    max-width: 320px;
    margin: 0 0 20px 0;
  }
}