/* ==========================================================================
   styles.css  —  all of the page's styling
   ==========================================================================

   You usually won't need to touch this. To re-colour everything, change the
   accent in data.js (meta.accent). To tweak the base shades/fonts, edit the
   variables in the ":root" block right below.

   Sections:
     1.  Theme variables
     2.  Reset & base
     3.  Layout helpers + chips/buttons
     4.  Intro heading
     5.  Work groups + project cards (with in-card carousel)
     6.  Lightbox / modal
     7.  Footer (optional)
     8.  Animations & reveal-on-scroll
     9.  Responsive
   ========================================================================== */


/* ============================ 1. THEME =================================== */
:root {
  /* --- Colours (dark theme) --- */
  --bg:            #0d0f13;
  --bg-2:          #101318;
  --surface:       #14181f;
  --surface-2:     #1a1f28;
  --border:        #262c37;
  --border-strong: #38404e;

  --text:          #e7ebf2;
  --text-muted:    #9aa4b4;
  --text-dim:      #69727f;

  --accent:        #7ee0c4;   /* overridden by data.js meta.accent */
  --accent-soft:   rgba(126, 224, 196, 0.12);
  --accent-line:   rgba(126, 224, 196, 0.35);
  --accent-ink:    #06231b;   /* text drawn on top of the accent */

  /* --- Type --- */
  /* Font stacks include common Japanese system fonts so 日本語 renders well
     with no downloads (offline-safe). */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
               "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas,
               "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, monospace;

  /* --- Shape & motion --- */
  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 10px 40px -12px rgba(0, 0, 0, 0.55);
  --shadow-lg:  0 30px 80px -20px rgba(0, 0, 0, 0.7);
  --ease:       cubic-bezier(0.22, 1, 0.36, 1);
  --wrap:       1180px;
}


/* ========================= 2. RESET & BASE ============================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;

  /* Subtle "engine docs" backdrop: faint dot grid + a soft accent glow up top. */
  background-image:
    radial-gradient(1100px 520px at 50% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.035) 1px, transparent 0);
  background-size: 100% 100%, 26px 26px;
  background-attachment: fixed;
}

img, video { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: 10px; left: 50%;
  transform: translate(-50%, -140%);
  z-index: 1000; background: var(--accent); color: var(--accent-ink);
  padding: 10px 18px; border-radius: 8px; font-weight: 600;
  transition: transform 0.2s var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); text-decoration: none; }

.noscript {
  margin: 40px auto; max-width: 600px; padding: 20px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}


/* ================= 3. LAYOUT HELPERS + CHIPS/BUTTONS ==================== */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* Small uppercase mono label, e.g. "// selected work" */
.kicker {
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent);
  display: inline-flex; align-items: center; gap: 8px;
}
.kicker::before { content: "//"; opacity: 0.6; }

/* Monospace tags used for technologies. */
.chip {
  display: inline-block; font-family: var(--font-mono); font-size: 0.74rem;
  color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px;
}

/* Buttons (used for the optional links inside the lightbox). */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font: 600 0.9rem/1 var(--font-sans); cursor: pointer; white-space: nowrap;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn .icon { width: 17px; height: 17px; flex: 0 0 auto; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent-line); }


/* ========================= 4. INTRO HEADING ============================ */
.intro {
  max-width: var(--wrap); margin: 0 auto;
  /* extra top space so the fixed language toggle never overlaps the heading */
  padding: clamp(66px, 9vw, 100px) 24px clamp(28px, 4vw, 44px);
}
.intro .kicker { margin-bottom: 16px; }
.intro-title { font-size: clamp(2rem, 5.5vw, 3.4rem); font-weight: 750; letter-spacing: -0.03em; }
.intro-sub { color: var(--text-muted); font-size: clamp(1rem, 2.4vw, 1.2rem); margin-top: 12px; max-width: 640px; }


/* ==================== 4b. LANGUAGE SWITCH ============================== */
/* Fixed, always-visible toggle (globe + EN / 日本語) on desktop and mobile. */
.langswitch {
  position: fixed; top: 12px; right: 14px; z-index: 150;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.langswitch:empty { display: none; }               /* nothing to show before JS runs */
.ls-globe { display: grid; place-items: center; width: 26px; height: 26px; color: var(--text-muted); flex: 0 0 auto; }
.ls-btn {
  font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; line-height: 1;
  padding: 7px 12px; border-radius: 999px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.ls-btn:hover { color: var(--text); }
.ls-btn.is-active { background: var(--accent); color: var(--accent-ink); }


/* ================= 5. WORK GROUPS + PROJECT CARDS ===================== */
.gallery-pad { padding-bottom: clamp(60px, 9vw, 120px); }

.work-group { padding: clamp(30px, 4.5vw, 52px) 0 0; }
.group-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.group-title { font-size: clamp(1.35rem, 3.2vw, 2rem); font-weight: 700; }
.group-desc { color: var(--text-dim); font-size: 0.95rem; }
.group-count {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* A project card. The whole card lifts on hover; the media area and the info
   area are the two clickable regions that open the lightbox. */
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.card:hover, .card:focus-within {
  transform: translateY(-4px); border-color: var(--accent-line); box-shadow: var(--shadow);
}

/* --- In-card carousel (the "project" media viewer) --- */
.card-media {
  position: relative; aspect-ratio: 16 / 10;
  background: var(--surface-2); overflow: hidden; cursor: pointer;
}
.card-media .cc-img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
}
.card:hover .card-media .cc-img { transform: scale(1.04); }

/* Prev / next arrows — appear on hover (desktop) or always (touch). */
.cc-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.35rem; line-height: 1; color: var(--text);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid var(--border); cursor: pointer;
  opacity: 0; transition: opacity 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.card-media:hover .cc-arrow, .cc-arrow:focus-visible { opacity: 1; }
.cc-arrow:hover { background: var(--surface-2); border-color: var(--accent-line); }
.cc-prev { left: 8px; } .cc-next { right: 8px; }

/* Dot indicators (shown when there are only a few media). */
.cc-dots { position: absolute; bottom: 9px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; gap: 6px; }
.cc-dot {
  width: 6px; height: 6px; padding: 0; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.4); cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.cc-dot:hover { background: rgba(255, 255, 255, 0.7); }
.cc-dot.is-active { background: var(--accent); transform: scale(1.35); }

/* Slide counter (e.g. "3 / 9"), top-right. */
.cc-count {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted);
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px;
}

/* Play glyph, centred, shown only when the current slide is a video. */
.cc-play { position: absolute; inset: 0; z-index: 2; display: none; place-items: center; pointer-events: none; }
.card-media.has-video .cc-play { display: grid; }
.cc-play svg { width: 48px; height: 48px; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.55)); }

.card-badge {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-ink); padding: 3px 8px; border-radius: 6px; font-weight: 600;
}

/* --- Card info (title / date / tech). A button so it's keyboard-openable. --- */
.card-info {
  display: flex; flex-direction: column; gap: 9px; flex: 1;
  width: 100%; text-align: left; cursor: pointer;
  padding: 14px 15px 16px; background: transparent; border: 0; color: inherit; font: inherit;
}
.card-title { font-size: 1.05rem; font-weight: 640; line-height: 1.3; transition: color 0.2s var(--ease); }
.card-info:hover .card-title { color: var(--accent); }
.card-date { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-dim); }
.card-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

/* Lazy images fade in once loaded. */
.lazy { opacity: 0; }
.lazy.loaded { opacity: 1; }


/* ======================= 6. LIGHTBOX / MODAL ========================= */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 40px);
}
.lightbox[hidden] { display: none; }

.lightbox-backdrop {
  position: absolute; inset: 0; background: rgba(4, 6, 9, 0.78);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.lightbox.is-open .lightbox-backdrop { opacity: 1; }

.lightbox-dialog {
  position: relative; width: min(1080px, 100%); max-height: 100%;
  display: grid; grid-template-columns: 1.55fr 1fr;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateY(14px) scale(0.985); opacity: 0;
  transition: transform 0.32s var(--ease), opacity 0.32s var(--ease);
}
.lightbox.is-open .lightbox-dialog { transform: none; opacity: 1; }

.lightbox-x {
  position: absolute; top: 10px; right: 12px; z-index: 3;
  width: 38px; height: 38px; line-height: 1; font-size: 1.6rem; color: var(--text);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.lightbox-x:hover { background: var(--surface-2); border-color: var(--accent-line); }

.lb-gallery { display: flex; flex-direction: column; background: #06080b; min-width: 0; }
.lb-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; aspect-ratio: 16 / 10; }
.lb-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lb-media img, .lb-media video { width: 100%; height: 100%; object-fit: contain; background: #06080b; }
.lb-media .lb-fade { animation: fadeIn 0.35s var(--ease); }

.lb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.7rem; line-height: 1; color: var(--text);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  border: 1px solid var(--border); cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.lb-arrow:hover { background: var(--surface-2); border-color: var(--accent-line); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-counter {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-muted);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px;
}

.lb-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; background: var(--surface); border-top: 1px solid var(--border); scrollbar-width: thin; }
.lb-thumb {
  flex: 0 0 auto; width: 68px; height: 44px; padding: 0;
  border-radius: 7px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--surface-2);
  opacity: 0.6; position: relative;
  transition: border-color 0.2s var(--ease), opacity 0.2s var(--ease);
}
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb-thumb:hover { opacity: 1; }
.lb-thumb.is-active { border-color: var(--accent); opacity: 1; }
.lb-thumb .play-badge { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,0.3); }

.lb-info { padding: clamp(20px, 3vw, 34px); overflow-y: auto; min-width: 0; }
.lb-date { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); margin-bottom: 8px; }
.lb-title { font-size: clamp(1.35rem, 3vw, 1.8rem); font-weight: 700; margin-bottom: 16px; }
.lb-desc p { color: var(--text-muted); margin: 0 0 12px; }
.lb-block { margin-top: 24px; }
.lb-block-label { font-family: var(--font-mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); margin-bottom: 10px; }
.lb-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.lb-notes { color: var(--text-muted); font-style: italic; border-left: 2px solid var(--accent-line); padding-left: 14px; }
.lb-notes p { margin: 0 0 8px; } .lb-notes p:last-child { margin-bottom: 0; }
.lb-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }


/* ====================== 7. FOOTER (optional) ========================= */
.site-footer { border-top: 1px solid var(--border); padding: 26px 0; margin-top: clamp(40px, 6vw, 80px); }
.site-footer[hidden] { display: none; }
.footer-note { color: var(--text-dim); font-size: 0.88rem; text-align: center; }


/* ================== 8. ANIMATIONS & REVEAL-ON-SCROLL ================= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

[data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
[data-reveal].is-visible { opacity: 1; transform: none; }
[data-reveal][style*="--i"] { transition-delay: calc(var(--i) * 55ms); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  [data-reveal] { opacity: 1; transform: none; }
}


/* ========================== 9. RESPONSIVE ============================ */
@media (max-width: 900px) {
  .lightbox-dialog { grid-template-columns: 1fr; grid-template-rows: auto 1fr; max-height: 100%; overflow-y: auto; }
  .lb-info { max-height: none; }
}

/* On touch devices (no hover), keep the carousel arrows visible. */
@media (hover: none) {
  .cc-arrow { opacity: 0.9; }
}

@media (max-width: 720px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .group-desc { display: none; }
  .lb-arrow { width: 38px; height: 38px; font-size: 1.4rem; }
}

@media (max-width: 420px) {
  .wrap, .intro { padding-left: 16px; padding-right: 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .langswitch { top: 10px; right: 10px; }
  .ls-btn { padding: 11px 13px; font-size: 0.82rem; }  /* bigger touch target on mobile */
}

/* Thin dark scrollbars where supported. */
* { scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
