/* ==========================================================================
   명언제조기 — 탁본(拓本) & 인장(印章) 모티프
   동서양 100인의 말을 돌에 새기고 종이에 옮겨 뜨는 탁본처럼,
   그리고 창작한 말은 붉은 인주로 도장을 찍듯 표시한다.
   ========================================================================== */

@font-face {
  font-family: "GmarketSans";
  src: url("/static/fonts/GmarketSansLight.woff") format("woff");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "GmarketSans";
  src: url("/static/fonts/GmarketSansMedium.woff") format("woff");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "GmarketSans";
  src: url("/static/fonts/GmarketSansBold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #1b1815;
  --ink-soft: #26221d;
  --ink-softer: #322c25;
  --stone: #4a433a;
  --stone-line: #55503f3d;
  --paper: #ede6d6;
  --paper-dim: #a89c86;
  --paper-dimmer: #7b715f;
  --seal: #c1432e;
  --seal-bright: #dd5138;
  --seal-dim: rgba(193, 67, 46, 0.16);

  --font-display: "GmarketSans", "Pretendard", sans-serif;
  --font-serif: "Noto Serif KR", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --container: 1180px;
  --radius-seal: 999px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 전체 배경에 은은한 탁본 종이 질감 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
}

a {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- 상단 헤더 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--ink) 82%, transparent);
  backdrop-filter: blur(6px);
  padding: 22px 0 14px;
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
}

.brand-mark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.15rem, 5vw, 1.5rem);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-tagline {
  font-size: 0.76rem;
  color: var(--paper-dimmer);
  font-weight: 500;
  letter-spacing: 0.02em;
  word-break: keep-all;
}

.filters {
  display: flex;
  gap: 6px;
  border: 1px solid var(--stone-line);
  padding: 4px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--paper-dimmer);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 16px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.filter-btn:hover {
  color: var(--paper);
}

.filter-btn.active {
  background: var(--seal);
  color: var(--paper);
}

/* ---------- 히어로 ---------- */

.hero {
  max-width: var(--container);
  margin: 0 auto;
  padding: 64px 28px 48px;
  position: relative;
  z-index: 2;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--seal-bright);
  letter-spacing: 0.14em;
  margin-bottom: 18px;
}

.hero-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2.1rem, 5.2vw, 3.7rem);
  line-height: 1.28;
  max-width: 15ch;
  margin: 0 0 20px;
}

.hero-title em {
  font-style: normal;
  color: var(--seal-bright);
}

.hero-desc {
  font-size: 1rem;
  color: var(--paper-dim);
  max-width: 46ch;
  line-height: 1.7;
  font-weight: 500;
}

/* ---------- 인물 그리드 ---------- */

.grid-section {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 28px 100px;
  position: relative;
  z-index: 2;
}

.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 1px;
  background: var(--stone-line);
  border: 1px solid var(--stone-line);
}

.person-card {
  background: var(--ink-soft);
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}

.person-card .portrait-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.person-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.15) brightness(0.95) sepia(0.12);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
}

.portrait-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(27, 24, 21, 0.15), rgba(27, 24, 21, 0.85) 92%);
  mix-blend-mode: multiply;
}

.person-card:hover img,
.person-card:focus-visible img {
  transform: scale(1.06);
  filter: grayscale(0.5) contrast(1.15) brightness(1) sepia(0.08);
}

.card-seal {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  opacity: 0;
  transform: scale(0.6) rotate(-12deg);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.person-card:hover .card-seal,
.person-card:focus-visible .card-seal {
  opacity: 1;
  transform: scale(1) rotate(-12deg);
}

.card-meta {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-name {
  display: block;
  font-weight: 700;
  font-size: 0.98rem;
}

.card-era {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--paper-dimmer);
  letter-spacing: 0.02em;
}

.person-card:focus-visible {
  outline: 2px solid var(--seal-bright);
  outline-offset: -2px;
}

/* ---------- 상세 뷰 ---------- */

.detail-view {
  max-width: var(--container);
  margin: 0 auto;
  padding: 32px 28px 120px;
  position: relative;
  z-index: 2;
}

.back-btn {
  background: none;
  border: none;
  color: var(--paper-dim);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 28px;
  transition: color 0.2s ease;
}

.back-btn:hover {
  color: var(--seal-bright);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 48px;
  align-items: start;
}

.detail-layout > * {
  min-width: 0;
}

.portrait-stage {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid var(--stone-line);
  background: var(--ink-soft);
}

.portrait-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.15) brightness(0.9) sepia(0.14);
}

.portrait-stage .portrait-tint {
  background: linear-gradient(185deg, rgba(27, 24, 21, 0.05) 30%, rgba(27, 24, 21, 0.92) 96%);
}

.quote-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 26px 26px;
  z-index: 3;
}

.quote-overlay-text {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.15rem, 2.1vw, 1.5rem);
  line-height: 1.55;
  margin: 0;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.quote-overlay-text::before {
  content: "“";
  color: var(--seal-bright);
}
.quote-overlay-text::after {
  content: "”";
  color: var(--seal-bright);
}


.quote-nav {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 3;
}

.quote-nav button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(237, 230, 214, 0.35);
  background: rgba(27, 24, 21, 0.5);
  color: var(--paper);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.quote-nav button:hover {
  background: var(--seal);
  border-color: var(--seal);
}

.quote-counter {
  position: absolute;
  top: 22px;
  left: 20px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--paper-dim);
  z-index: 3;
  background: rgba(27, 24, 21, 0.5);
  padding: 4px 9px;
  border: 1px solid rgba(237, 230, 214, 0.2);
}

/* ---------- 인물 정보 + 생성기 패널 ---------- */

.person-info {
  padding-top: 4px;
}

.info-title {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 6px;
}

.info-sub {
  font-size: 0.9rem;
  color: var(--paper-dimmer);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.info-desc {
  color: var(--paper-dim);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 30px;
}

.divider {
  border: none;
  border-top: 1px solid var(--stone-line);
  margin: 0 0 26px;
}

.generator-panel {
  background: var(--ink-soft);
  border: 1px solid var(--stone-line);
  padding: 26px 24px;
}

.generator-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--seal-bright);
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.generator-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 18px;
}

.topic-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  min-width: 0;
}

.topic-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--stone-line);
  color: var(--paper);
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.topic-input:focus {
  border-color: var(--seal);
}

.topic-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.topic-input-wrap .topic-input {
  width: 100%;
}

.topic-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--ink);
  border: 1px solid var(--stone-line);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.topic-hint.is-hidden {
  opacity: 0;
}

.topic-hint-track {
  display: flex;
  white-space: nowrap;
  animation: topic-marquee 13s linear infinite;
}

.topic-hint-track span {
  padding: 0 14px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--paper-dimmer);
}

@keyframes topic-marquee {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

.seal-btn {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  border-radius: var(--radius-seal);
  border: none;
  background: var(--seal);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  filter: url(#roughen);
  transition: background 0.2s ease, transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
}

.seal-btn:hover:not(:disabled) {
  background: var(--seal-bright);
}

.seal-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.seal-btn:disabled {
  background: var(--stone);
  color: var(--paper-dimmer);
  cursor: not-allowed;
  filter: none;
}

.generator-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usage-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}

.usage-dots .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--seal);
  background: transparent;
  transition: background 0.2s ease;
}

.usage-dots .dot.used {
  background: var(--seal);
}

.usage-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--paper-dimmer);
}

.generator-status {
  font-size: 0.82rem;
  color: var(--paper-dimmer);
  min-height: 1.2em;
}

.generator-status.error {
  color: var(--seal-bright);
}

/* ---------- 생성 결과 팝업 ---------- */

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.result-modal[hidden] {
  display: none;
}

.result-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 7, 0.78);
  backdrop-filter: blur(4px);
}

.result-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--ink-soft);
  border: 1px solid var(--stone-line);
  padding: 16px;
}

.result-close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--stone-line);
  background: var(--ink);
  color: var(--paper);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-close:hover {
  background: var(--seal);
  border-color: var(--seal);
}

.result-portrait {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

.result-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.15) brightness(0.9) sepia(0.14);
}

.result-portrait .portrait-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(185deg, rgba(27, 24, 21, 0.1) 26%, rgba(27, 24, 21, 0.94) 96%);
  mix-blend-mode: multiply;
}

.result-seal {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--seal);
  color: var(--paper);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: url(#roughen);
}

.result-text-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 24px 22px 22px;
}

.result-quote {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  line-height: 1.55;
  margin: 0 0 10px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.result-quote::before {
  content: "“";
  color: var(--seal-bright);
}
.result-quote::after {
  content: "”";
  color: var(--seal-bright);
}

.result-person {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--paper-dim);
  margin: 0;
}

.result-disclaimer {
  font-size: 0.72rem;
  color: var(--paper-dimmer);
  line-height: 1.5;
  padding: 12px 6px 0;
  margin: 0;
}

.result-actions {
  display: flex;
  gap: 8px;
  padding: 12px 6px 0;
}

.result-action-btn {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--stone-line);
  background: transparent;
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.result-action-btn:hover {
  border-color: var(--seal);
}

.result-action-btn.primary {
  background: var(--seal);
  border-color: var(--seal);
  font-weight: 700;
}

.result-action-btn.primary:hover {
  background: var(--seal-bright);
}

.result-share-status {
  font-size: 0.74rem;
  color: var(--paper-dimmer);
  padding: 8px 6px 0;
  margin: 0;
  min-height: 1.2em;
}

/* ---------- 푸터 ---------- */

.site-footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: 40px 28px 60px;
  color: var(--paper-dimmer);
  font-size: 0.76rem;
  line-height: 1.7;
  border-top: 1px solid var(--stone-line);
  position: relative;
  z-index: 2;
}

.legal-nav {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.legal-nav a {
  color: var(--paper-dim);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.legal-nav a:hover {
  color: var(--seal-bright);
}

/* ---------- 약관/정책 페이지 ---------- */

.legal-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 28px 40px;
  position: relative;
  z-index: 2;
}

.legal-page h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin: 0 0 6px;
}

.legal-updated {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--paper-dimmer);
  margin: 0 0 32px;
}

.legal-page h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin: 32px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--stone-line);
}

.legal-page h2:first-of-type {
  margin-top: 0;
}

.legal-page p,
.legal-page li {
  color: var(--paper-dim);
  font-size: 0.92rem;
  line-height: 1.75;
}

.legal-page ul {
  padding-left: 1.2em;
  margin: 0 0 16px;
}

.legal-page li {
  margin-bottom: 8px;
}

.legal-page a {
  color: var(--seal-bright);
}

/* ---------- 반응형 ---------- */

@media (max-width: 860px) {
  .detail-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .portrait-stage {
    aspect-ratio: 4 / 3.4;
  }
}

@media (max-width: 560px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 0 18px;
    gap: 10px;
  }

  .hero,
  .grid-section,
  .detail-view,
  .site-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .filters {
    width: 100%;
    overflow-x: auto;
  }

  .person-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .topic-row {
    flex-direction: column;
  }

  .seal-btn {
    width: 100%;
    height: 52px;
    border-radius: 8px;
    filter: none;
  }
}

/* ---------- 모션 감소 ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
