/* DnG — 픽셀 개발자의 작업실. 외부 폰트 없음. 스크립트는 예시 화면 팝업용 자체 /assets/gallery.js만. 그림은 /assets의 자체 픽셀 SVG를 CSS 배경으로만 쓴다. */

:root {
  --canvas: #f6f1e6;
  --panel: #ebe2d0;
  --desk: #c4b8a2;
  --ink: #26231f;
  --ink-soft: #5b544b;
  --orange: #d9601f;
  --lime: #a6cf4f;

  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans KR", "Noto Sans CJK KR", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", monospace;

  --line: 4px solid var(--ink);
  --gutter: clamp(1rem, 5vw, 4rem);
  --measure: 76rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 예시 화면 팝업이 열려 있는 동안 배경 문서 스크롤을 잠근다(gallery.js가 class를 붙이고 닫으면 뗀다). */
html.gallery-locked {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
}

:lang(ko) {
  word-break: keep-all;
  line-break: strict;
}

h1,
h2,
h3,
p,
dl,
dd,
ul {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--mono);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

/* 모노 스택의 한글은 시스템 고딕으로 대체되지만 공백은 고정폭이라 넓다. 한국어일 때만 단어 간격을 줄인다. */
:is(h1, h2, h3, .gallery-dialog-title, .eyebrow, .item-name, .product-kicker, .facts dt, .pixel-button, .site-nav a):lang(ko) {
  word-spacing: -0.25em;
}

a {
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

::selection {
  background: var(--lime);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.wrap {
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin-inline: auto;
}

.marker {
  color: var(--orange);
  font-family: var(--mono);
  font-weight: 800;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  background: var(--ink);
  color: var(--canvas);
  font-family: var(--mono);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
}

/* Header */
.site-header {
  border-bottom: var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 1rem;
  padding-block: 0.5rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  font-family: var(--mono);
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.wordmark-mark {
  width: 2rem;
  height: 2rem;
  background: url("/assets/favicon.svg") center / contain no-repeat;
  box-shadow: 3px 3px 0 var(--orange);
}

.site-nav {
  flex-basis: 100%;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-inline: -0.5rem;
  padding: 0;
  list-style: none;
}

.site-nav a,
.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.site-nav a:hover {
  text-decoration: underline;
}

.lang-item {
  margin-left: auto;
  padding-left: 0.5rem;
}

.lang-switch {
  padding-inline: 0.75rem;
  border: 3px solid var(--ink);
  background: var(--canvas);
}

.site-nav .lang-switch:hover,
.lang-switch:hover {
  background: var(--lime);
  text-decoration: none;
}

/* Hero */
.hero {
  padding-block: clamp(2.5rem, 7vw, 5rem) clamp(3.5rem, 8vw, 6rem);
}

.hero-inner {
  display: grid;
  gap: clamp(2.5rem, 6vw, 4rem);
}

.eyebrow {
  margin-bottom: 1.25rem;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
}

.hero h1 {
  max-width: 14em;
  font-size: clamp(2rem, 1.2rem + 3.6vw, 3.75rem);
  line-height: 1.12;
}

.lead {
  max-width: 34em;
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  line-height: 1.65;
}

/* Workshop scene: CRT·키보드 책상 위의 카트리지(전자가마수호대)와 커피잔(BrewLog) */
.workshop {
  min-width: 0;
  border: var(--line);
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--ink);
}

.desk-scene {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "crt crt"
    "cart mug"
    "board board";
  align-items: end;
  column-gap: 0.75rem;
  padding: 1.5rem 0.75rem;
}

.desk-crt {
  grid-area: crt;
  justify-self: center;
  width: min(100%, 15rem);
  margin-bottom: 1.5rem;
  aspect-ratio: 160 / 136;
  background: url("/assets/crt.svg") center bottom / contain no-repeat;
}

.desk-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}

.desk-cartridge {
  grid-area: cart;
}

.desk-mug {
  grid-area: mug;
}

.item-tag {
  display: block;
  width: 100%;
  max-width: 13rem;
  padding: 0 0.5rem 0.5rem;
  border: 3px solid var(--ink);
  background: var(--canvas);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 80ms steps(2), box-shadow 80ms steps(2), background-color 80ms steps(2);
}

.item-tag::before {
  content: "";
  display: block;
  height: 6px;
  margin: 0 -0.5rem 0.5rem;
  background: var(--orange);
}

.desk-mug .item-tag::before {
  background: var(--lime);
}

.item-name {
  display: block;
  font-family: var(--mono);
  font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.0625rem);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: break-word;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.item-status {
  display: block;
  margin-top: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.45;
}

.item-art {
  display: block;
  background: center bottom / contain no-repeat;
  transition: transform 80ms steps(2);
}

.desk-cartridge .item-art {
  width: 4rem;
  aspect-ratio: 64 / 72;
  background-image: url("/assets/cartridge.svg");
}

.desk-mug .item-art {
  width: 4rem;
  aspect-ratio: 1;
  background-image: url("/assets/mug.svg");
}

.desk-item:hover .item-tag {
  background: var(--lime);
}

.desk-item:hover .item-art {
  transform: translateY(-4px);
}

.desk-item:active .item-tag {
  box-shadow: 0 0 0 var(--ink);
  transform: translate(4px, 4px);
}

.desk-item:focus-visible {
  outline-offset: 6px;
}

.desk-board {
  grid-area: board;
  position: relative;
  height: 1.25rem;
  border: var(--line);
  background: var(--desk);
}

.desk-board::before,
.desk-board::after {
  content: "";
  position: absolute;
  top: 100%;
  width: 1rem;
  height: calc(1.5rem + 4px);
  background: var(--ink);
}

.desk-board::before {
  left: 0.75rem;
}

.desk-board::after {
  right: 0.75rem;
}

/* Pixel button */
.pixel-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 3px solid var(--ink);
  background: var(--lime);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 80ms steps(2), box-shadow 80ms steps(2), background-color 80ms steps(2);
}

button.pixel-button {
  cursor: pointer;
}

.pixel-button:hover {
  background: var(--canvas);
  box-shadow: 6px 6px 0 var(--ink);
  transform: translate(-2px, -2px);
}

.pixel-button:active {
  box-shadow: 0 0 0 var(--ink);
  transform: translate(4px, 4px);
}

/* Sections */
.section {
  border-top: var(--line);
  padding-block: clamp(3.5rem, 8vw, 6rem);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}

.section-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  padding: 0.125rem 0.5rem;
  background: var(--ink);
  color: var(--canvas);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.section-head h2 {
  min-width: 0;
}

.section h2 {
  font-size: clamp(1.625rem, 1.2rem + 1.8vw, 2.5rem);
}

/* Projects: 카트리지 라벨 목록 */
.product-list {
  display: grid;
  gap: 2rem;
}

.product {
  min-width: 0;
  border: var(--line);
  background: var(--canvas);
  box-shadow: 8px 8px 0 var(--ink);
}

.product-kicker {
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--canvas);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 600;
}

.product-game .product-kicker {
  border-left: 12px solid var(--orange);
}

.product-brew .product-kicker {
  border-left: 12px solid var(--lime);
}

.product-title {
  padding: 1.25rem 1rem 0;
  font-size: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
}

.product-body {
  padding: 1rem 1rem 1.5rem;
}

.product-body > p {
  max-width: 36em;
}

.facts {
  margin-top: 1.25rem;
}

/* 글자를 크게 키워 폭이 모자라면 dt 위, dd 아래로 쌓는다. */
.facts > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  padding-block: 0.5rem;
  border-top: 2px solid var(--ink);
}

.facts > div:last-child {
  border-bottom: 2px solid var(--ink);
}

.facts dt,
.facts dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.facts dt {
  flex: 0 1 7rem;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 600;
}

.facts dd {
  flex: 1 1 6rem;
  font-size: 0.9375rem;
}

/* BrewLog 예시 화면: 메인은 우측 끝 열기 버튼만. 이미지는 네이티브 <dialog>(gallery.js) 안에서 한 장씩 넘긴다. */
.gallery {
  min-width: 0;
  margin-top: 2rem;
}

/* flex는 버튼만 감싼 CTA 줄에만 준다. 버튼은 글자 폭을 유지하고, 좁으면 max-width 100% 안에서 줄바꿈한다. */
.gallery-cta {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.gallery-open {
  min-width: 0;
}

.gallery-fallback-note {
  margin-top: 1rem;
  font-size: 0.9375rem;
}

.gallery-fallback {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.gallery-fallback a {
  display: block;
  min-height: 44px;
  padding-block: 0.5rem;
  overflow-wrap: anywhere;
}

/* 열림·닫힘은 dialog 기본 동작에 맡기고 display를 덮지 않는다. 패널이 dialog를 꽉 채워 배경 클릭만 dialog 자신에 닿는다. */
.gallery-dialog {
  width: calc(100% - 1rem);
  max-width: 40rem;
  max-height: calc(100vh - 1rem);
  max-height: calc(100dvh - 1rem);
  margin: auto;
  padding: 0;
  border: var(--line);
  background: var(--canvas);
  color: var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.gallery-dialog::backdrop {
  background: var(--ink);
  opacity: 0.82;
}

.gallery-dialog-panel {
  padding: 1rem 1rem 1.25rem;
}

.gallery-dialog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.gallery-dialog-title {
  min-width: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.gallery-dialog .pixel-button {
  justify-content: center;
  min-width: 44px;
}

.gallery-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}

.gallery-counter {
  min-width: 3.5rem;
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.gallery-slides {
  margin: 1rem 0 0;
  padding: 1rem 0.75rem 1.25rem;
  list-style: none;
  border: var(--line);
  background: var(--panel);
}

.gallery-figure {
  margin: 0;
}

/* 세로형 PNG가 짧은 화면을 넘지 않게 높이를 제한하고 비율은 유지한다. 그래도 넘치면 dialog 안에서 스크롤한다. */
.gallery-shot {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 70vh;
  margin-inline: auto;
  border: 3px solid var(--ink);
  background: var(--canvas);
  box-shadow: 6px 6px 0 var(--ink);
}

.gallery-figure figcaption {
  max-width: 36em;
  margin: 1rem auto 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* Contact: 어두운 콘솔 패널 */
.contact {
  background: var(--ink);
  color: var(--canvas);
}

.contact .section-index {
  background: var(--lime);
  color: var(--ink);
}

.contact-body p {
  color: var(--panel);
}

.contact-mail {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 1.25rem;
  padding: 0.5rem 0.875rem;
  border: 3px solid var(--canvas);
  color: var(--lime);
  font-family: var(--mono);
  font-size: clamp(1rem, 0.7rem + 2.4vw, 2.25rem);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--orange);
}

.contact-mail:hover {
  background: var(--lime);
  color: var(--ink);
}

/* Footer */
.site-footer {
  border-top: var(--line);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.875rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem 2rem;
}

.footer-inner .lang-switch {
  color: var(--ink);
}

/* 404 */
.not-found {
  padding-block: clamp(3rem, 10vw, 7rem);
}

.not-found-inner {
  display: grid;
  gap: 2.5rem;
  align-items: center;
}

.not-found-screen {
  width: min(100%, 16rem);
  padding: 1.5rem 1rem;
  border: var(--line);
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--ink);
}

.not-found-screen .desk-crt {
  width: 100%;
  margin-bottom: 0;
}

.not-found h1 {
  font-size: clamp(1.75rem, 1.2rem + 3vw, 3rem);
}

.not-found-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 48rem) {
  .header-inner {
    flex-wrap: nowrap;
    padding-block: 0.75rem;
  }

  .site-nav {
    flex-basis: auto;
  }

  .site-nav ul {
    flex-wrap: nowrap;
    gap: 0.25rem;
  }

  .lang-item {
    margin-left: 0.75rem;
  }

  .desk-scene {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.75fr) minmax(0, 1fr);
    grid-template-areas:
      "cart crt mug"
      "board board board";
    column-gap: 1rem;
    padding-inline: 1.5rem;
  }

  .desk-crt {
    width: min(100%, 20rem);
    margin-bottom: 0;
  }

  .desk-cartridge .item-art {
    width: 5rem;
  }

  .desk-mug .item-art {
    width: 4.5rem;
  }

  .desk-board::before {
    left: 2rem;
  }

  .desk-board::after {
    right: 2rem;
  }

  .product-body {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    column-gap: clamp(2rem, 5vw, 3rem);
    align-items: start;
  }

  .product-body > p {
    grid-row: span 2;
  }

  .product-body .facts {
    margin-top: 0.25rem;
  }

  .product-body > .gallery {
    grid-column: 1 / -1;
  }

  .not-found-inner {
    grid-template-columns: 16rem minmax(0, 1fr);
    gap: 4rem;
  }
}

@media (min-width: 64rem) {
  .section > .wrap {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    column-gap: clamp(2rem, 4vw, 4rem);
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0;
  }

  .section > .wrap > :not(.section-head) {
    grid-column: 2;
  }
}

@media (min-width: 80rem) {
  .hero-inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: center;
  }

  .hero h1 {
    font-size: 3.25rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pixel-button,
  .item-tag,
  .item-art {
    transition: none;
  }

  .pixel-button:hover,
  .pixel-button:active,
  .desk-item:hover .item-art,
  .desk-item:active .item-tag {
    transform: none;
  }
}
