/* Layout: small centered header (mascot logo, nav, socials) above a wide edge-to-edge
   thumbnail grid with centered captions. The work is the only color on the page.
   Deliberately light-only. */
:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --ink: #1b1b1b;
  --sub: #8f8f8f;
  --faint: #bdbdbd;
  --line: #e2e2e2;
  --accent: #f0709f;
  --brand-x: #000000;
  --brand-youtube: #ff0000;
  --cap-title: #444444;
  --cap-meta: #ababab;

  /* one family site-wide, like the reference: Proxima Nova when an Adobe Fonts kit is linked,
     otherwise its free look-alike Figtree; Korean falls through to Pretendard */
  --font-body: "proxima-nova", "Proxima Nova", Figtree, Pretendard, "Noto Sans JP", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  /* in Japanese, kanji should come from the Japanese face rather than the Korean one */
  --font-body-ja: "proxima-nova", "Proxima Nova", Figtree, "Noto Sans JP", Pretendard, "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --font-caption: var(--font-body);
  --font-mono: var(--font-body);

  --gutter: 8px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* Japanese has no spaces between words, so it needs normal line breaking (keep-all would never wrap) */
html:lang(ja) { --font-body: var(--font-body-ja); }
html:lang(ja) body { word-break: normal; line-break: strict; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header: two mirrored halves around an open center. Logo + name with the role line
   beneath on the left half (pushed toward the center), links on the right half. WORKS drops
   to a second row as the label above the grid, aligned with the first thumbnail's left edge. ---------- */
.top {
  --top-gap: clamp(120px, 30vw, 460px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 44px var(--top-gap);
  max-width: 1400px;
  margin: 0 auto;
  padding-block: calc(56px + env(safe-area-inset-top, 0px)) 16px;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
.brand { grid-area: 1 / 1; justify-self: end; display: flex; align-items: center; gap: 14px; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.top-right {
  grid-area: 1 / 2;
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.top .nav { grid-area: 2 / 1; justify-self: start; }
/* JP / KR / EN switcher, top-right corner of the header */
.lang {
  grid-area: 1 / 2;
  justify-self: end;
  align-self: start;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.lang button {
  font: inherit;
  letter-spacing: inherit;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--sub);
  cursor: pointer;
  transition: color .2s;
}
.lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

/* "+" (add a video) at the right end of the WORKS row, lined up with the grid's right edge;
   only signed-in editors get it */
.add-work {
  grid-area: 2 / 2;
  justify-self: end;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  margin-right: -6px;
  border-radius: 50%;
  color: var(--ink);
  transition: background .2s, color .2s, transform .2s;
}
.add-work svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.add-work:hover { background: var(--ink); color: var(--surface); transform: rotate(90deg); }
.top-role {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cap-title);
  white-space: nowrap;
}
/* "CONTACT :: mail" line under the role text, same type but quieter */
.top-contact {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--sub);
  white-space: nowrap;
}
.top-contact a { color: var(--cap-title); transition: color .2s; }
.top-contact a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.logo { display: flex; align-items: center; }
.logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--cap-title);
}
.logo-mark { display: grid; place-items: center; height: 34px; }
/* an image logo drawn on white blends into the page background instead of showing a white box */
.logo-mark:has(img) { height: auto; }
.logo-mark img { height: 64px; width: auto; max-width: none; mix-blend-mode: multiply; transition: transform .3s ease; }
.logo:hover .logo-mark img { transform: translateY(-3px) rotate(-6deg); }
.mascot { width: 34px; height: 26px; transition: transform .3s ease; }
.mascot path:first-child { fill: var(--surface); stroke: var(--ink); stroke-width: 2.2; }
.mascot circle { fill: var(--ink); }
.mascot .mouth { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.logo:hover .mascot { transform: translateY(-3px) rotate(-6deg); }

.nav { display: flex; gap: 22px; }
.nav a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--sub);
  transition: color .2s;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* X and Instagram logos in their brand colors, side by side, each with its name */
.social { list-style: none; padding: 0; margin: 0; display: flex; align-items: center; gap: 24px; }
.social a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--cap-title);
  white-space: nowrap;
  transition: color .2s;
}
.social a:hover { color: var(--ink); }
.social svg { flex: none; transition: transform .2s; }
.social a:hover svg { transform: scale(1.12); }
.social .x svg { width: 19px; height: 19px; fill: var(--brand-x); }
.social .instagram svg { width: 22px; height: 22px; }
.social .youtube svg { width: 28px; height: 20px; }
.social .youtube .yt-bg { fill: var(--brand-youtube); }
.social .youtube .yt-play { fill: #ffffff; }

/* ---------- main ---------- */
#view {
  min-width: 0;
  outline: none;
  padding-bottom: 64px;
}
#view.enter > * { animation: rise .45s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes rise { from { opacity: .3; transform: translateY(8px); } }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.foot {
  margin-top: 72px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
}

/* ---------- works grid: 4 columns of 16:9 thumbnails, centered two-line captions (cappu) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 30px 14px;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}

.card { display: flex; flex-direction: column; gap: 9px; min-width: 0; text-align: center; }
.card-media {
  aspect-ratio: 16 / 9;
  max-width: 100%;
  overflow: hidden;
  background: var(--line);
}
.card-media > * { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .7, .3, 1); }
.card:hover .card-media > * { transform: scale(1.04); }
.card-cap { padding-inline: 10px; }
.card-title {
  font-family: var(--font-caption);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--cap-title);
}
.card-meta {
  font-family: var(--font-caption);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--cap-meta);
  margin-top: 4px;
}
.card-meta b { font-weight: 700; }
.card-meta b::after { content: " |  "; white-space: pre; }

/* ---------- placeholder art (shown until real images are added) ---------- */
.ph {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 1px 1px, rgb(255 255 255 / .35) 1.2px, transparent 1.6px) 0 0 / 14px 14px,
    linear-gradient(var(--ang, 135deg), var(--a), var(--b));
  overflow: hidden;
}
.ph-label {
  position: relative;
  z-index: 1;
  padding: 0 8%;
  font-weight: 700;
  font-size: clamp(1rem, 2.1vw, 1.7rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-align: center;
  color: #ffffff;
  text-shadow: 2px 2px 0 rgb(27 27 27 / .8);
  transform: rotate(-4deg);
}
.ph-dot { position: absolute; border-radius: 50%; background: rgb(255 255 255 / .45); }
.ph-dot.d1 { width: 38%; aspect-ratio: 1; left: -8%; bottom: -18%; }
.ph-dot.d2 { width: 16%; aspect-ratio: 1; right: 8%; top: 10%; background: rgb(255 255 255 / .3); }
.ph.big .ph-label { font-size: clamp(1.6rem, 4.4vw, 3.2rem); }

/* ---------- project ---------- */
.back {
  display: block;
  width: fit-content;
  margin: 0 0 10px auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--sub);
}
.back:hover { color: var(--ink); }

.project-head { text-align: center; margin-bottom: 28px; }
.project-head h1 { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 700; line-height: 1.35; }
.project-head .card-meta { font-size: 12px; margin-top: 6px; }
.project-year { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--faint); margin-top: 4px; }

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  overflow: hidden;
  background: var(--ink);
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player > img { width: 100%; height: 100%; object-fit: cover; }
.player .play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.player .play span {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
  box-shadow: 0 6px 24px rgb(0 0 0 / .2);
}
.player .play svg { width: 20px; height: 20px; fill: var(--ink); margin-left: 4px; }

/* credit block under the video, laid out like a YouTube description: line breaks kept, left-aligned */
.credit {
  margin-top: 20px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--cap-title);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.credit a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.credit a:hover { color: var(--accent); }

.stills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gutter); }
.stills > * { aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden; }
.stills > *:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.stills img { width: 100%; height: 100%; object-fit: cover; }

/* previous / next project arrows sit just outside the video's left and right edges */
.stage { position: relative; }
.step {
  position: absolute;
  top: 50%;
  width: 44px; height: 44px;
  margin-top: -22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgb(0 0 0 / .08);
  transition: background .2s, color .2s, transform .2s;
}
.step svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.step.prev { left: -68px; }
.step.prev svg { transform: scaleX(-1); }
.step.next { right: -68px; }
.step:hover { background: var(--ink); color: var(--surface); }
.step.prev:hover { transform: translateX(-3px); }
.step.next:hover { transform: translateX(3px); }

/* when there's no room beside the video, the arrows move onto its edges */
@media (max-width: 1200px) {
  .step { width: 38px; height: 38px; margin-top: -19px; background: rgb(255 255 255 / .85); }
  .step.prev { left: 10px; }
  .step.next { right: 10px; }
}

.empty { color: var(--sub); text-align: center; }
.empty a { color: var(--ink); text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 900px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* once the right block would run out of room, everything stacks centered; WORKS stays left above the grid */
@media (max-width: 900px) {
  .top {
    gap: 20px;
    padding-block: calc(32px + env(safe-area-inset-top, 0px)) 16px;
  }
  .lang { grid-area: 1 / 1 / 2 / -1; margin-top: -16px; }
  .brand { grid-area: 2 / 1 / 3 / -1; justify-self: center; }
  .top-right { grid-area: 3 / 1 / 4 / -1; justify-self: center; align-items: center; }
  .top-role { white-space: normal; }
  .top .nav { grid-area: 4 / 1 / 5 / -1; margin-top: 12px; }
  .add-work { grid-area: 4 / 1 / 5 / -1; margin-top: 12px; }
}

@media (max-width: 560px) {
  .top {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .stills { grid-template-columns: minmax(0, 1fr); }
  .stills > *:first-child:nth-last-child(odd) { grid-column: auto; }
}

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

/* ---------- edit mode (#edit) ---------- */
.editor {
  max-width: 1400px;
  margin: 0 auto;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
.ed-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.ed-head h1 { font-size: 20px; font-weight: 700; }
.ed-note { font-size: 12px; color: var(--sub); margin-top: 4px; }
.ed-note code { font-size: 12px; color: var(--cap-title); }
.ed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ed-status { font-size: 12px; color: var(--sub); max-width: 46ch; }
.ed-status.ok { color: #2a9d63; }
.ed-status.warn { color: #b7791f; }
.ed-status.err { color: #d23b5c; }
.ed-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.ed-btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.ed-btn:hover { border-color: var(--ink); }

.ed-body { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 32px; align-items: start; }
.ed-side { display: grid; gap: 12px; }
.ed-add {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 12px;
  border: 1px dashed var(--faint);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.ed-add:hover { border-color: var(--ink); background: var(--surface); }
.ed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.ed-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow .15s, transform .15s, background .15s;
}
.ed-item.is-active { background: var(--surface); border-color: var(--line); }
/* picked up for reordering */
.ed-list.is-sorting, .ed-list.is-sorting .ed-pick { cursor: grabbing; }
.ed-item.is-dragging {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 10px 24px rgb(0 0 0 / .14);
  transform: scale(1.02);
}
.ed-grip {
  flex: none;
  display: grid;
  place-items: center;
  width: 14px;
  height: 28px;
  color: var(--faint);
  cursor: grab;
  touch-action: none;
}
.ed-grip svg { width: 8px; height: 14px; fill: currentColor; }
.ed-item:hover .ed-grip { color: var(--sub); }
.ed-thumb img { -webkit-user-drag: none; pointer-events: none; }
.ed-pick {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.ed-thumb { flex: none; width: 72px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 3px; background: var(--line); }
.ed-thumb > * { width: 100%; height: 100%; object-fit: cover; }
.ed-thumb .ph-label { font-size: 7px; text-shadow: 1px 1px 0 rgb(27 27 27 / .8); }
.ed-item-text { min-width: 0; display: grid; }
.ed-item-text b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item-text small { font-size: 11px; color: var(--sub); }
.ed-item-tools { display: flex; gap: 2px; }
.ed-item-tools button {
  width: 24px; height: 24px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--sub);
  cursor: pointer;
  font-size: 12px;
}
.ed-item-tools button:hover:not(:disabled) { background: var(--line); color: var(--ink); }
.ed-item-tools button:disabled { opacity: .3; cursor: default; }
.ed-hint, .ed-empty { font-size: 12px; color: var(--sub); }

.ed-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.ed-form { display: grid; gap: 16px; }
.ed-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ed-field { display: grid; gap: 6px; min-width: 0; }
.ed-field label { font-size: 12px; font-weight: 700; }
.ed-field label span { font-weight: 400; color: var(--sub); margin-left: 4px; }
.ed-field input, .ed-field textarea, .ed-field select {
  font: inherit;
  font-size: 13px;
  width: 100%;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.ed-field textarea { resize: vertical; line-height: 1.7; }
.ed-field input:focus, .ed-field textarea:focus, .ed-field select:focus { outline: none; border-color: var(--ink); }
/* category dropdown: native arrow replaced by a chevron that matches the rest of the form */
.ed-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
  cursor: pointer;
}
.ed-help { font-size: 11px; color: var(--sub); }
.ed-help.err { color: #d23b5c; }
.ed-preview { display: grid; gap: 10px; position: sticky; top: 16px; }
.ed-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--sub); }
.ed-card { max-width: 340px; pointer-events: none; }
.ed-video .player { max-width: 100%; }

@media (max-width: 1100px) {
  .ed-main { grid-template-columns: minmax(0, 1fr); }
  .ed-preview { position: static; }
}
@media (max-width: 760px) {
  .ed-body { grid-template-columns: minmax(0, 1fr); }
  .ed-list { max-height: none; }
}

/* ---------- editor sign-in (#login) ---------- */
.login {
  max-width: 360px;
  margin: 40px auto 0;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
.login h1 { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.login-note { font-size: 13px; color: var(--cap-title); line-height: 1.7; }
.login-note code { font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 12px; font-weight: 700; }
.login-form input {
  font: inherit;
  font-size: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.login-form input:focus { outline: none; border-color: var(--ink); }
.login-form .ed-btn { justify-self: start; margin-top: 4px; }
.login-msg { font-size: 12px; color: #d23b5c; min-height: 1.5em; }
