/*
  Base ink-style theme variables and typography.
  Keep visuals minimal, spacious, and text-first.
*/

:root {
  --bg: #f5f1eb;
  --ink: #1a1a1a;
  --ink-muted: #666;
  --accent: #8b2500;

  --font-serif: "LXGW WenKai", "Source Han Serif SC", serif;

  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-s: 0.75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  --line-height: 1.9;
  --max-width: 64rem;
  --thin-stroke: 1px solid var(--ink);
}

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

html {
  font-size: 16px;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: var(--line-height);
  letter-spacing: 0.02em;
}

.page-transition {
  position: relative;
}

.page-transition::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg);
  pointer-events: none;
  opacity: 1;
  animation: ink-wash-in 900ms cubic-bezier(0.3, 0.6, 0.2, 1) forwards;
}

.page-transition.is-leaving::before {
  animation: ink-wash-out 500ms cubic-bezier(0.3, 0.6, 0.2, 1) forwards;
}

@keyframes ink-wash-in {
  from {
    opacity: 1;
    filter: blur(6px);
  }
  to {
    opacity: 0;
    filter: blur(0);
  }
}

@keyframes ink-wash-out {
  from {
    opacity: 0;
    filter: blur(0);
  }
  to {
    opacity: 1;
    filter: blur(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-transition::before,
  .page-transition.is-leaving::before {
    animation: none;
    opacity: 0;
    filter: none;
  }
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
  position: relative;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-m) 0;
  font-weight: 500;
}

p {
  margin: 0 0 var(--space-m) 0;
  color: var(--ink);
}

small,
.muted {
  color: var(--ink-muted);
}

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 0.1em;
}

a:hover,
a:focus {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

ul,
ol {
  padding-left: var(--space-xl);
  margin: 0 0 var(--space-l) 0;
}

hr {
  border: 0;
  border-top: var(--thin-stroke);
  margin: var(--space-xl) 0;
}

.ink-panel {
  padding: var(--space-l) 0;
  border-top: var(--thin-stroke);
}

.scroll-header {
  padding-bottom: var(--space-xl);
  border-bottom: var(--thin-stroke);
}

.scroll-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-m);
  margin-top: var(--space-m);
}

.scroll-footer {
  padding-top: var(--space-xl);
  border-top: var(--thin-stroke);
}

.sound-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.sound-block {
  padding-bottom: var(--space-s);
}

.sound-list {
  list-style: none;
  padding: 0;
  margin: var(--space-s) 0 0;
}

.sound-item {
  padding: var(--space-xs) 0;
  border-bottom: var(--thin-stroke);
}

.sound-item:last-child {
  border-bottom: 0;
}

.sound-link {
  display: inline-block;
}

.sound-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sound-meta {
  margin: var(--space-2xs) 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.sound-action {
  margin-top: var(--space-m);
}

/* Ink-style line art for clouds and mountains. */
.ink-decor {
  margin: var(--space-xl) 0;
  pointer-events: none;
}

.ink-decor--top {
  margin-top: 0;
}

.ink-decor--bottom {
  margin-bottom: 0;
}

.ink-decor svg {
  width: 100%;
  height: auto;
  display: block;
}

.ink-decor svg + svg {
  margin-top: var(--space-xs);
}

.ink-clouds,
.ink-mountains {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
}

.ink-clouds--secondary,
.ink-mountains--secondary {
  stroke: var(--ink-muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.status-block {
  padding: var(--space-s) 0 var(--space-m);
  border-bottom: var(--thin-stroke);
}

.status-block:last-child {
  border-bottom: 0;
}

.status-value {
  font-size: 1.2rem;
  margin-bottom: var(--space-xs);
}

.status-progress {
  margin: var(--space-s) 0;
}

.progress-track {
  border: var(--thin-stroke);
  height: 0.4rem;
  width: 100%;
  position: relative;
}

.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
}

.status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-l);
  margin-top: var(--space-l);
}

.status-meta p {
  margin-bottom: 0;
}

.cultivation-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.cultivation-block {
  padding-bottom: var(--space-s);
}

.technique-list {
  list-style: none;
  padding: 0;
  margin: var(--space-s) 0 0;
}

.technique-item {
  padding: var(--space-xs) 0;
  border-bottom: var(--thin-stroke);
}

.technique-item:last-child {
  border-bottom: 0;
}

.technique-link {
  display: inline-block;
}

.technique-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.cultivation-detail {
  margin-top: var(--space-s);
}

.detail-title {
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
}

.cultivation-action {
  margin-top: var(--space-m);
}

.event-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.event-block {
  padding-bottom: var(--space-s);
}

.event-list {
  list-style: none;
  padding: 0;
  margin: var(--space-s) 0 0;
}

.event-item {
  padding: var(--space-xs) 0;
  border-bottom: var(--thin-stroke);
}

.event-item:last-child {
  border-bottom: 0;
}

.event-item.is-locked {
  opacity: 0.6;
}

.event-link {
  display: inline-block;
}

.event-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.event-meta {
  margin: var(--space-2xs) 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.event-detail {
  margin-top: var(--space-s);
}

.event-action {
  margin-top: var(--space-m);
}

.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.npc-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.npc-block {
  padding-bottom: var(--space-s);
}

.npc-list {
  list-style: none;
  padding: 0;
  margin: var(--space-s) 0 0;
}

.npc-item {
  padding: var(--space-xs) 0;
  border-bottom: var(--thin-stroke);
}

.npc-item:last-child {
  border-bottom: 0;
}

.npc-item.is-locked {
  opacity: 0.6;
}

.npc-link {
  display: inline-block;
}

.npc-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.npc-meta {
  margin: var(--space-2xs) 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.npc-detail {
  margin-top: var(--space-s);
}

.npc-action {
  margin-top: var(--space-m);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-l);
}

.inventory-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.inventory-block {
  padding-bottom: var(--space-s);
}

.inventory-items {
  list-style: none;
  padding: 0;
  margin: var(--space-s) 0 0;
}

.inventory-item {
  padding: var(--space-xs) 0;
  border-bottom: var(--thin-stroke);
}

.inventory-item:last-child {
  border-bottom: 0;
}

.inventory-item.is-locked {
  opacity: 0.6;
}

.inventory-link {
  display: inline-block;
}

.inventory-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.inventory-meta {
  margin: var(--space-2xs) 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.inventory-detail {
  margin-top: var(--space-s);
}

.inventory-action {
  margin-top: var(--space-m);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-l);
}

.achievement-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-l);
}

.achievement-block {
  padding-bottom: var(--space-s);
}

.achievement-list {
  list-style: none;
  padding: 0;
  margin: var(--space-s) 0 0;
}

.achievement-item {
  padding: var(--space-xs) 0;
  border-bottom: var(--thin-stroke);
}

.achievement-item:last-child {
  border-bottom: 0;
}

.achievement-item.is-locked {
  opacity: 0.6;
}

.achievement-link {
  display: inline-block;
}

.achievement-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.achievement-meta {
  margin: var(--space-2xs) 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.achievement-detail {
  margin-top: var(--space-s);
}

.log-scroll {
  margin-top: var(--space-m);
  padding: var(--space-m) 0;
  border-top: var(--thin-stroke);
  border-bottom: var(--thin-stroke);
  overflow-x: auto;
  overflow-y: hidden;
}

.log-list {
  list-style: none;
  display: flex;
  flex-direction: row-reverse;
  gap: var(--space-l);
  margin: 0;
  padding: 0 var(--space-s);
  min-height: 18rem;
}

.log-entry {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border-left: var(--thin-stroke);
  padding-left: var(--space-s);
  min-height: 16rem;
}

.log-entry p {
  margin: 0 0 var(--space-s) 0;
}

.log-entry p:last-child {
  margin-bottom: 0;
}

.log-type {
  color: var(--accent);
  letter-spacing: 0.18em;
}

.log-time {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.log-title {
  font-size: 1.05rem;
}

@media (max-width: 720px) {
  main {
    padding: var(--space-xl) var(--space-m);
  }

  .status-meta {
    flex-direction: column;
    gap: var(--space-s);
  }

  .log-list {
    min-height: 14rem;
    gap: var(--space-m);
  }

  .log-entry {
    padding-left: var(--space-xs);
  }
}

@media (max-width: 900px) {
  main {
    padding: var(--space-xl) var(--space-l);
  }

  .sound-panel,
  .status-grid,
  .cultivation-panel,
  .event-panel,
  .npc-panel,
  .inventory-panel,
  .achievement-panel {
    grid-template-columns: 1fr;
    gap: var(--space-l);
  }

  .scroll-nav {
    gap: var(--space-s);
  }
}

@media (max-width: 600px) {
  html {
    font-size: 15px;
  }

  main {
    padding: var(--space-l) var(--space-m);
  }

  ul,
  ol {
    padding-left: var(--space-l);
  }

  .scroll-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .npc-action,
  .inventory-action {
    flex-direction: column;
    gap: var(--space-s);
  }

  .log-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 22rem;
  }

  .log-list {
    flex-direction: column-reverse;
    min-height: auto;
    padding: 0;
  }

  .log-entry {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    border-left: 0;
    border-top: var(--thin-stroke);
    padding: var(--space-s) 0 0;
    min-height: auto;
  }

  .log-entry:first-child {
    border-top: 0;
    padding-top: 0;
  }
}

@media (max-width: 420px) {
  html {
    font-size: 14px;
  }

  main {
    padding: var(--space-l) var(--space-s);
  }

  .status-value,
  .detail-title {
    font-size: 1rem;
  }
}
