/* 방랑 운세 — 한지·먹·주인(朱印) 테마 (모바일 우선)
   종이 위에 먹으로 쓴 나그네의 기록장. 강조색은 도장 빛 주홍 하나만 씁니다. */
:root {
  --paper: #f3ecdd;
  --paper-2: #f8f3e8;
  --paper-3: #ebe1cc;
  --ink: #2b2620;
  --ink-2: #4a4239;
  --muted: #6f6556;
  --line: rgba(43, 38, 32, 0.22);
  --line-strong: rgba(43, 38, 32, 0.55);
  --earth: #8a7a5c;
  --moss: #6b6f55;
  --seal: #b8432f;
  --seal-ink: #fbf4e6;
  --focus: #b8432f;
  --radius: 4px;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", "BatangChe", serif;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  background-color: var(--paper);
  /* 한지 결: 미세한 잡티 + 긴 섬유 */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .2' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .42 0 0 0 0 .3 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)'/%3E%3C/svg%3E");
  word-break: keep-all;
  overflow-wrap: break-word;
}

a { color: var(--ink); text-decoration-color: var(--seal); text-underline-offset: 3px; }
a:hover { color: var(--seal); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 8px 14px; font-weight: 700;
}
.skip:focus { top: 12px; }

.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* 헤더 — 고정하지 않아 본문을 가리지 않습니다 */
.site-header { background: transparent; }
.site-header .wrap { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding-top: 18px; }
.brand { align-self: center; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 34px; height: 34px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.15; font-family: var(--serif); font-weight: 700; font-size: 1.3rem; letter-spacing: 0.12em; }
.brand-name small { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 400; font-size: 0.72rem; letter-spacing: 0.08em; color: var(--muted); }
.brand:hover { color: var(--ink); }
.nav { border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); position: relative; }
.nav::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; border-bottom: 1px solid var(--line); }
.nav ul { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; }
.nav li + li { border-left: 1px solid var(--line); }
.nav a {
  display: block; text-align: center; padding: 10px 2px; color: var(--ink-2); text-decoration: none;
  font-family: var(--serif); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.02em; position: relative;
}
.nav a:hover { color: var(--seal); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 800; }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 50%; top: 4px; width: 6px; height: 6px; margin-left: -3px; background: var(--seal); transform: rotate(45deg);
}

/* 공통 */
main { padding: 12px 0 48px; }
.hero { padding: 26px 0 6px; text-align: left; }
.hero h1 { font-family: var(--serif); font-size: 2rem; font-weight: 800; line-height: 1.3; margin: 2px 0 10px; letter-spacing: 0.04em; color: var(--ink); }
.hero p { margin: 0; color: var(--ink-2); max-width: 34em; }
.ornament { display: block; width: 160px; height: 24px; margin: 0 0 6px; color: var(--earth); }

.panel {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 22px 18px;
  margin-top: 22px;
  box-shadow: 4px 4px 0 var(--paper-3);
}

.eyebrow { margin: 0; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.1em; font-family: var(--serif); }
.hero .eyebrow::before { content: ""; display: inline-block; width: 18px; height: 1px; background: var(--seal); vertical-align: middle; margin-right: 8px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 0.85rem; margin: 20px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); }

/* 폼 — 공책에 적는 밑줄 칸 */
.form-grid { display: grid; gap: 18px; }
.field label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-family: var(--serif); font-weight: 700; margin-bottom: 4px; }
.field .hint { font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 0.8rem; }
input[type="date"], select {
  width: 100%; min-height: 48px; padding: 10px 4px; font: inherit; font-size: 1.05rem; color: var(--ink);
  background: transparent; border: 0; border-bottom: 2px solid var(--ink); border-radius: 0;
}
select { appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus-visible, select:focus-visible { outline: none; border-bottom-color: var(--seal); background-color: rgba(184, 67, 47, 0.05); }
input[aria-invalid="true"] { border-bottom-color: var(--seal); }
.error { color: var(--seal); font-size: 0.88rem; margin: 6px 0 0; min-height: 1em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 22px; width: 100%;
  font: inherit; font-family: var(--serif); font-weight: 800; font-size: 1.05rem; letter-spacing: 0.14em; cursor: pointer;
  color: var(--paper-2); background: var(--ink); border: 0; border-radius: var(--radius);
}
.btn::after { content: ""; width: 8px; height: 8px; background: var(--seal); transform: rotate(45deg); }
.btn:hover { background: #3a332b; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); width: auto; letter-spacing: 0.06em; }
.btn.ghost:hover { background: var(--paper-3); }

/* 결과 */
#result:focus, h2[tabindex]:focus { outline: none; }
.result-head { text-align: left; padding-bottom: 14px; border-bottom: 1px solid var(--line-strong); }
.result-head h2 { font-family: var(--serif); font-size: 1.4rem; margin: 2px 0 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tag { display: inline-block; padding: 1px 10px; border: 1px solid var(--line-strong); border-radius: 2px; font-size: 0.85rem; color: var(--ink); text-decoration: none; background: var(--paper); }
a.tag:hover { border-color: var(--seal); color: var(--seal); }

/* 총운 — 붉은 낙관(도장) 점수 */
.overall { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 20px; }
.overall h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.15rem; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.overall p { margin: 0 0 8px; }
.seal {
  justify-self: start; width: 96px; height: 96px; display: grid; place-items: center; position: relative;
  background: var(--seal); color: var(--seal-ink); border-radius: 6px; transform: rotate(-4deg);
  box-shadow: inset 0 0 0 4px var(--seal), inset 0 0 0 6px var(--seal-ink);
  font-family: var(--serif); font-size: 2.3rem; font-weight: 800; line-height: 1;
}
.seal::after { content: "總運"; position: absolute; bottom: 12px; font-size: 0.62rem; letter-spacing: 0.3em; font-weight: 700; padding-left: 0.3em; }
.seal span { margin-top: -10px; }
.advice { font-family: var(--serif); font-weight: 600; padding: 10px 0 0 0; margin-top: 10px; border-top: 1px dashed var(--line); }

.score { font-size: 0.88rem; color: var(--muted); white-space: nowrap; font-family: var(--sans); }
.score strong { color: var(--ink); font-size: 1.15rem; font-family: var(--serif); }
.tier { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 2px; font-size: 0.74rem; font-weight: 700; border: 1px solid currentColor; font-family: var(--sans); line-height: 1.6; }
.tier-2 { color: var(--seal-ink); background: var(--seal); border-color: var(--seal); }
.tier-1 { color: var(--ink); }
.tier-0 { color: var(--moss); border-style: dashed; }

.cats { display: grid; gap: 0; margin-top: 18px; border-top: 1px solid var(--line-strong); }
.cat { padding: 14px 0 6px; border-bottom: 1px solid var(--line); }
.cat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cat h3 { margin: 0; font-size: 1.02rem; font-family: var(--serif); }
.cat p { margin: 8px 0 8px; }
/* 붓으로 그은 듯한 먹선 게이지 */
.meter { height: 8px; margin-top: 8px; background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 10%); border-bottom: 1px solid var(--line); }
.meter span { display: block; height: 100%; background: var(--ink); border-radius: 0 6px 6px 0 / 0 4px 4px 0; clip-path: polygon(0 20%, 100% 0, 98% 100%, 0 85%); }

.lucky { margin-top: 20px; }
.lucky h3 { margin: 0 0 10px; font-size: 1.02rem; font-family: var(--serif); }
.lucky dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin: 0; border: 1px solid var(--line-strong); }
.lucky dl div { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); }
.lucky dl div:nth-child(2n) { border-right: 0; }
.lucky dl div:nth-child(n+3) { border-bottom: 0; }
.lucky dt { color: var(--muted); font-size: 0.78rem; font-family: var(--serif); letter-spacing: 0.1em; }
.lucky dd { margin: 0; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-strong); flex: none; }
.swatch.sm { width: 12px; height: 12px; vertical-align: -1px; margin: 0 4px 0 2px; }

/* 바로가기 — 이정표 */
.shortcuts { display: grid; grid-template-columns: 1fr; gap: 0; margin-top: 28px; border-top: 1px solid var(--line-strong); }
.shortcuts a { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); font-family: var(--serif); font-weight: 700; }
.shortcuts a::after { content: "→"; margin-left: auto; color: var(--muted); font-family: var(--sans); }
.shortcuts a span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--ink); font-family: var(--serif); font-size: 1.2rem; line-height: 1; }
.shortcuts a:hover { color: var(--seal); }
.shortcuts a:hover span { border-color: var(--seal); }
.shortcuts a:hover::after { color: var(--seal); }

/* 목록 (띠·별자리) — 장부 */
.list { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 0; border-top: 2px solid var(--ink); }
.row { display: grid; grid-template-columns: 48px 1fr; gap: 14px; padding: 18px 2px; border-bottom: 1px solid var(--line-strong); scroll-margin-top: 24px; }
.row.is-target { background: var(--paper-2); box-shadow: inset 3px 0 0 var(--seal); padding-left: 10px; }
.row-mark { width: 48px; height: 48px; display: grid; place-items: center; border: 1.5px solid var(--ink); color: var(--ink); font-family: var(--serif); font-size: 1.45rem; font-weight: 700; background: var(--paper-2); }
.row.is-target .row-mark { background: var(--seal); border-color: var(--seal); color: var(--seal-ink); }
.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.row h2 { margin: 0; font-size: 1.12rem; font-family: var(--serif); }
.row p { margin: 4px 0 0; }
.row-sub { color: var(--muted); font-size: 0.82rem; }
.row-extra { color: var(--muted); font-size: 0.85rem; }
.stars { color: var(--ink); letter-spacing: 1px; font-size: 0.85rem; }
.stars .dim { color: var(--line); }
.kw { display: inline-block; margin-left: 6px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 2px; color: var(--ink); background: var(--paper); }

/* 타로 */
.spread { list-style: none; margin: 22px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.spread li { margin: 0; }
.card-back { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 4px; transition: transform 0.2s ease, opacity 0.3s ease; }
.card-back:hover:not(:disabled) { transform: translateY(-4px) rotate(-1.5deg); }
.card-back:disabled { cursor: default; }
.spread.is-done .card-back:not(.is-chosen) { opacity: 0.3; }
.card-back.is-chosen { transform: translateY(-6px); outline: 2px solid var(--seal); outline-offset: 2px; }
.card-svg { display: block; width: 100%; height: auto; }
.card-svg.is-reversed { transform: rotate(180deg); }
.reading { margin-top: 24px; display: grid; gap: 18px; }
.reading-card { width: min(190px, 58%); margin: 0 auto; filter: drop-shadow(4px 5px 0 rgba(43, 38, 32, 0.18)); }
.reading-text h2 { font-family: var(--serif); font-size: 1.5rem; margin: 2px 0 10px; }
.reading-text .tags { margin-bottom: 10px; }
.orient { font-size: 0.8rem; padding: 1px 8px; border-radius: 2px; vertical-align: middle; border: 1px solid currentColor; font-family: var(--sans); }
.orient.up { color: var(--seal-ink); background: var(--seal); border-color: var(--seal); }
.orient.rev { color: var(--moss); border-style: dashed; }
details { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 10px; }
summary { cursor: pointer; font-family: var(--serif); font-weight: 600; }
summary:hover { color: var(--seal); }
.actions { text-align: center; margin-top: 18px; }
.flip-in { animation: flip 0.6s ease both; }
@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } to { transform: rotateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .flip-in { animation: none; } .card-back { transition: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* 푸터 — 먹빛 띠 */
.site-footer { background: var(--ink); color: #cfc5b2; padding: 28px 0 36px; font-size: 0.84rem; }
.site-footer .disclaimer { color: var(--paper); margin: 0 0 14px; padding-left: 12px; border-left: 3px solid var(--seal); }
.site-footer .disclaimer strong { font-family: var(--serif); }
.site-footer p { margin: 4px 0; }
.site-footer p:last-child { margin-top: 16px; font-family: var(--serif); letter-spacing: 0.06em; color: #a79c88; }
.site-footer a { color: var(--paper); }

@media (min-width: 640px) {
  .site-header .wrap { flex-direction: row; align-items: center; justify-content: space-between; padding-top: 22px; padding-bottom: 6px; border-bottom: 1px solid var(--line-strong); }
  .brand { align-self: auto; }
  .nav, .nav::after { border: 0; }
  .nav ul { display: flex; gap: 4px; }
  .nav li + li { border-left: 0; }
  .nav a { padding: 8px 10px; }
  .nav a[aria-current="page"]::before { top: auto; bottom: -2px; }
  .hero { padding-top: 40px; }
  .hero h1 { font-size: 2.6rem; }
  .panel { padding: 30px; box-shadow: 6px 6px 0 var(--paper-3); }
  .form-grid { grid-template-columns: 1fr 1fr; align-items: start; column-gap: 28px; }
  .form-grid .btn { grid-column: 1 / -1; }
  .overall { grid-template-columns: 112px 1fr; align-items: start; gap: 22px; }
  .seal { width: 104px; height: 104px; margin-top: 6px; }
  .cats { grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
  .cat { padding: 14px 16px 6px; border-bottom: 0; }
  .cat + .cat { border-left: 1px solid var(--line); }
  .cat:first-child { padding-left: 0; }
  .cat:last-child { padding-right: 0; }
  .lucky dl { grid-template-columns: repeat(4, 1fr); }
  .lucky dl div { border-bottom: 0; }
  .lucky dl div:nth-child(2n) { border-right: 1px solid var(--line); }
  .lucky dl div:last-child { border-right: 0; }
  .shortcuts { grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
  .shortcuts a { border-bottom: 0; padding: 16px 14px; }
  .shortcuts a + a { border-left: 1px solid var(--line); }
  .list { grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .spread { grid-template-columns: repeat(11, 1fr); gap: 8px; }
  .reading { grid-template-columns: 190px 1fr; align-items: start; gap: 28px; }
  .reading-card { width: 190px; }
}
