:root {
  /* Design font token: Space Grotesk** Grotesk* Groteskk */
  --clay: #B86F3E;
  --paper: #F4E7C8;
  --ink: #3A2618;
  --stamp: #D94E2F;
  --moss: #5F7044;
  --brass: #C09A55;
  --charcoal: #16110D;
  --hanji: #D8C2A0;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body: "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  --meta: "Archivo", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #D8C2A0 0 12%, transparent 34%), linear-gradient(135deg, #B86F3E 0%, #D8C2A0 48%, #F4E7C8 100%);
  font-family: var(--body);
  overflow-x: hidden;
}

body::before {
  content: "Grotesk**";
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
}

button { font: inherit; color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: .22;
  background-image: radial-gradient(#3A2618 1px, transparent 1px), radial-gradient(#F4E7C8 1px, transparent 1px);
  background-size: 7px 9px, 13px 11px;
  mix-blend-mode: multiply;
}

.site-shell { position: relative; }

.index-tabs {
  position: fixed;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: grid;
  gap: 12px;
}

.tab {
  width: 42px;
  height: 62px;
  border: 1px solid rgba(58, 38, 24, .35);
  background: #F4E7C8;
  clip-path: polygon(0 0, 100% 10%, 100% 100%, 12% 90%);
  box-shadow: 6px 8px 0 rgba(22, 17, 13, .18);
  cursor: pointer;
  font-family: var(--meta);
  font-weight: 700;
}

.tab.is-active { background: #C09A55; color: #16110D; transform: translateX(8px); }

.memory-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(244,231,200,.72), transparent 35%), linear-gradient(120deg, #B86F3E, #D8C2A0 64%, #C09A55);
}

.gate-panel {
  position: absolute;
  inset: -10% auto -10% auto;
  width: 56vw;
  background: linear-gradient(145deg, #3A2618, #B86F3E 45%, #C09A55);
  z-index: 4;
  transition: transform 1600ms cubic-bezier(.19, 1, .22, 1);
  box-shadow: inset 0 0 80px rgba(22,17,13,.45);
}

.gate-left { left: -6vw; clip-path: polygon(0 0, 84% 0, 100% 100%, 0 100%); }
.gate-right { right: -6vw; clip-path: polygon(16% 0, 100% 0, 100% 100%, 0 100%); }
.gate-open .gate-left { transform: translateX(-78%) rotate(-2deg); }
.gate-open .gate-right { transform: translateX(78%) rotate(2deg); }

.gate-symbols {
  position: absolute;
  inset: 9vh 9vw;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: rgba(58,38,24,.2);
  font-family: var(--display);
  font-size: clamp(2rem, 8vw, 7rem);
  transform: rotate(-7deg);
}

.gate-symbols span:nth-child(even) { align-self: flex-end; color: rgba(217,78,47,.16); }

.gate-content {
  position: relative;
  z-index: 8;
  width: min(860px, 84vw);
  text-align: center;
  padding: 58px 42px;
  background: rgba(244,231,200,.72);
  border: 1px solid rgba(58,38,24,.22);
  clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 92%);
  box-shadow: 0 38px 90px rgba(22,17,13,.28);
}

.archive-kicker, .stamp {
  font-family: var(--meta);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 700;
  font-size: .76rem;
  color: var(--moss);
}

h1, h2, h3 { font-family: var(--display); margin: 0; color: var(--charcoal); }
h1 { font-size: clamp(4rem, 13vw, 11rem); line-height: .82; letter-spacing: -.07em; }
h2 { font-size: clamp(2.2rem, 5vw, 5.6rem); line-height: .9; letter-spacing: -.055em; }
h3 { font-size: clamp(1.35rem, 2vw, 2rem); letter-spacing: -.04em; }

.lead { max-width: 630px; margin: 28px auto; font-size: 1.12rem; line-height: 1.8; }

.seal-stage { height: 170px; position: relative; display: grid; place-items: center; perspective: 800px; }
.seal-stone {
  width: 112px;
  height: 126px;
  border-radius: 24px 18px 20px 16px;
  background: linear-gradient(145deg, #D8C2A0, #B86F3E 45%, #3A2618 120%);
  box-shadow: inset -14px -18px 22px rgba(58,38,24,.25), inset 9px 8px 18px rgba(244,231,200,.36), 0 28px 32px rgba(22,17,13,.27);
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  animation: sealTurn 2600ms cubic-bezier(.22, .8, .2, 1) both;
}
.seal-face { color: #F4E7C8; border: 2px solid rgba(244,231,200,.7); padding: 14px; font-family: var(--display); font-weight: 700; }
.seal-shadow { position: absolute; width: 170px; height: 32px; border-radius: 50%; background: rgba(22,17,13,.22); bottom: 12px; filter: blur(6px); }

@keyframes sealTurn { 0% { transform: rotateY(-32deg) rotateZ(-5deg) translateY(-18px); } 72% { transform: rotateY(7deg) rotateZ(2deg) translateY(0); } 100% { transform: rotateY(0) rotateZ(0); } }

.enter-gate, .citation-charm {
  border: 1px solid rgba(58,38,24,.36);
  background: #C09A55;
  padding: 12px 22px;
  clip-path: polygon(8% 0, 100% 0, 92% 100%, 0 100%);
  font-family: var(--meta);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 7px 8px 0 rgba(58,38,24,.18);
}

.courtyard-index {
  min-height: 100vh;
  padding: 110px 7vw 130px 92px;
  background: linear-gradient(180deg, rgba(244,231,200,.9), rgba(216,194,160,.86)), radial-gradient(circle at 80% 10%, rgba(95,112,68,.25), transparent 28%);
}

.section-heading { width: min(940px, 100%); margin: 0 0 48px auto; }
.section-heading p:last-child { max-width: 690px; line-height: 1.8; }

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 118px;
  gap: 24px;
  transition: opacity .5s ease;
}

.artifact-tile {
  position: relative;
  grid-column: span 4;
  grid-row: span 3;
  padding: 24px;
  background: linear-gradient(145deg, rgba(244,231,200,.98), rgba(216,194,160,.96));
  border: 1px solid rgba(58,38,24,.22);
  clip-path: polygon(8% 0, 100% 0, 100% 86%, 92% 100%, 0 100%, 0 12%);
  box-shadow: 0 20px 0 rgba(58,38,24,.08), 0 32px 48px rgba(22,17,13,.18);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .55s ease, filter .55s ease, opacity .55s ease;
}

.artifact-tile:hover, .artifact-tile.selected { transform: translateY(-12px) rotate(-.35deg); filter: saturate(1.06); }
.artifact-tile.dimmed { opacity: .38; filter: sepia(.35); }
.artifact-tile.wide { grid-column: span 7; }
.artifact-tile.tall { grid-column: span 5; grid-row: span 4; }
.artifact-tile.high { grid-row: span 4; }
.artifact-tile.long { grid-column: span 8; grid-row: span 3; }

.artifact-tile::before {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px dashed rgba(192,154,85,.4);
  clip-path: inherit;
  pointer-events: none;
}

.object { height: 48%; position: relative; display: grid; place-items: center; }
.object::after { content: ""; position: absolute; width: 58%; height: 18px; bottom: 6px; border-radius: 50%; background: rgba(22,17,13,.16); filter: blur(7px); }
.roof-tile span { width: 210px; height: 82px; border-radius: 12px 50px 18px 44px; background: linear-gradient(135deg, #5F7044, #3A2618); transform: rotate(-9deg); box-shadow: inset 18px 12px 18px rgba(244,231,200,.15); }
.talisman span { padding: 44px 22px; background: #F4E7C8; border-top: 18px solid #D94E2F; box-shadow: 12px 18px 0 rgba(58,38,24,.11); transform: rotate(5deg); font-family: var(--meta); color: #D94E2F; }
.drawer span { width: 210px; height: 110px; background: linear-gradient(180deg, #3A2618, #B86F3E); border: 12px solid #C09A55; box-shadow: inset 0 34px 0 rgba(244,231,200,.13); transform: rotate(2deg); }
.bowl span { width: 175px; height: 92px; border-radius: 50%; background: radial-gradient(ellipse at 50% 28%, #F4E7C8 0 26%, #C09A55 27% 45%, #5F7044 46% 100%); transform: rotate(-4deg); }
.book-spines span { width: 84%; height: 82px; background: repeating-linear-gradient(90deg, #3A2618 0 34px, #C09A55 34px 45px, #5F7044 45px 82px, #D8C2A0 82px 92px); transform: skewX(-8deg); box-shadow: -9px 9px 0 rgba(217,78,47,.28); }
.hinge span { width: 90px; height: 150px; background: linear-gradient(90deg, #C09A55, #D8C2A0, #B86F3E); border-radius: 44px; box-shadow: inset 0 0 0 13px rgba(58,38,24,.22); transform: rotate(13deg); }

.tile-copy { position: relative; z-index: 2; }
.tile-copy p { line-height: 1.65; margin-bottom: 0; }
.stamp.disputed { color: #D94E2F; }

.unsettled:hover .talisman, .unsettled:hover .stamp.disputed, .shake { animation: paperShake .42s linear 2; }
@keyframes paperShake { 0%,100% { transform: translateX(0) rotate(0); } 18% { transform: translateX(-4px) rotate(-1.3deg); } 38% { transform: translateX(5px) rotate(1.1deg); } 64% { transform: translateX(-3px) rotate(.6deg); } 82% { transform: translateX(2px) rotate(-.7deg); } }

.revision-room {
  min-height: 100vh;
  padding: 120px 7vw 90px 92px;
  background: linear-gradient(135deg, #3A2618, #16110D 70%);
  color: #F4E7C8;
}

.reading-chamber {
  min-height: 70vh;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 290px) minmax(340px, 660px) minmax(150px, 1fr);
  gap: 22px;
  align-items: center;
}

.reader-panel, .margin-note, .selected-object {
  background: rgba(244,231,200,.92);
  color: #3A2618;
  border: 1px solid rgba(192,154,85,.5);
  box-shadow: 0 34px 72px rgba(0,0,0,.3);
}

.reader-panel { padding: clamp(28px, 5vw, 62px); clip-path: polygon(0 0, 100% 5%, 94% 100%, 0 94%); }
.reader-panel p { line-height: 1.85; font-size: 1.05rem; }
.margin-note { padding: 20px; clip-path: polygon(12% 0, 100% 0, 88% 100%, 0 100%); transform: rotate(-3deg); }
.right-note { transform: rotate(3deg); }
.margin-note span { font-family: var(--meta); color: #D94E2F; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; font-size: .72rem; }

.selected-object { height: 260px; display: grid; place-items: center; clip-path: polygon(0 10%, 92% 0, 100% 90%, 8% 100%); background: linear-gradient(145deg, #D8C2A0, #B86F3E); transform: translateY(-18px); }
.mini-seal { width: 116px; height: 116px; border-radius: 26px; background: #3A2618; color: #F4E7C8; display: grid; place-items: center; font-family: var(--display); font-weight: 700; box-shadow: 0 24px 30px rgba(22,17,13,.3); }

.citation-strip { margin-top: 36px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.triangle-marker { width: 0; height: 0; border-left: 17px solid transparent; border-right: 17px solid transparent; border-bottom: 30px solid #D94E2F; filter: drop-shadow(5px 4px 0 rgba(58,38,24,.18)); }
.red-ghost { color: rgba(217,78,47,.35); font-family: var(--meta); letter-spacing: .12em; text-transform: uppercase; transform: translateX(-4px); }

.stamp-burst::after {
  content: "disputed";
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-9deg);
  z-index: 40;
  color: rgba(217,78,47,.5);
  border: 6px solid rgba(217,78,47,.42);
  border-radius: 50%;
  padding: 30px 26px;
  font-family: var(--meta);
  text-transform: uppercase;
  letter-spacing: .15em;
  animation: ghostFade .8s ease both;
}

@keyframes ghostFade { from { opacity: 0; transform: translate(-50%, -50%) scale(.78) rotate(-9deg); } 35% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -50%) scale(1.22) rotate(-9deg); } }

@media (max-width: 900px) {
  .index-tabs { left: 8px; }
  .courtyard-index, .revision-room { padding-left: 62px; padding-right: 22px; }
  .artifact-grid { grid-template-columns: repeat(6, 1fr); grid-auto-rows: 112px; }
  .artifact-tile, .artifact-tile.wide, .artifact-tile.tall, .artifact-tile.high, .artifact-tile.long { grid-column: span 6; grid-row: span 3; }
  .reading-chamber { grid-template-columns: 1fr; }
  .margin-note { transform: none; }
}
