@font-face {
  font-family: 'Chenyuluoyan';
  src: url('https://cdn.jsdelivr.net/gh/Chenyu-otf/chenyuluoyan_thin@main/ChenYuluoyan-2.0-Thin.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

:root {
  --bg-color: #1a1714;          /* warm ink black */
  --panel-bg: #221e19;           /* lifted sienna panel */
  --panel-bg-soft: #2a2520;      /* one step brighter for input fields */
  --text-main: #e8dfcf;          /* parchment cream */
  --text-muted: #897f70;         /* faded ink wash */
  --accent: #c4a374;             /* worn brass / dim gold */
  --accent-soft: rgba(196, 163, 116, 0.18);
  --border-color: #3a322a;       /* warm shadow line */
  --border-soft: #2c2620;
  --shadow-color: rgba(0, 0, 0, 0.45);
  --danger: #c98a8a;             /* dusty rose */
  --font-main: 'Chenyuluoyan', 'Noto Serif TC', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-main);
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(196, 163, 116, 0.06), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(0, 0, 0, 0.4), transparent 70%),
    url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23noise)' opacity='0.06'/%3E%3C/svg%3E");
}

/* Header Styles */
.main-header {
  padding: 2vh 5vw;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--panel-bg) 0%, #1f1b16 100%);
  box-shadow: 0 4px 24px var(--shadow-color);
  height: 20vh;
  display: flex;
  align-items: center;
  position: relative;
}

.main-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
  opacity: 0.35;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.intro-text {
  flex: 1;
}

.site-title {
  font-size: 5vh;
  margin-bottom: 1vh;
  color: var(--text-main);
  font-weight: normal;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.intro-text p {
  font-size: 2.2vh;
  line-height: 1.5;
  color: var(--text-muted);
}

.qr-container {
  width: 18vh;
  height: 18vh;
  border: 1px solid var(--border-color);
  padding: 1vh;
  background: #f0e6d4;
  box-shadow: 0 4px 18px var(--shadow-color), 0 0 0 1px rgba(196, 163, 116, 0.2);
  border-radius: 4px;
}

.qr-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.35) contrast(0.95) brightness(0.95);
  border-radius: 2px;
}

/* Main Display */
.hero-board {
  flex: 1;
  width: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 3vh;
  overflow: hidden;
}

.articles-grid {
  position: relative;
  width: 80vw;
  height: 100%;
}

.article-card {
  width: 75vw;
  height: 30vh;
  background: linear-gradient(155deg, var(--panel-bg) 0%, #1e1a15 100%);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2.5vh 3vw;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 50%;
  transform-origin: center center;
  transition: top 1.8s cubic-bezier(0.25, 1, 0.5, 1),
              transform 1.8s cubic-bezier(0.25, 1, 0.5, 1),
              opacity 1.8s cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 1.8s cubic-bezier(0.25, 1, 0.5, 1),
              border-color 1.8s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: 0 12px 40px var(--shadow-color), inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

/* Subtle corner decoration */
.article-card::before,
.article-card::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid var(--accent);
  opacity: 0.35;
  transition: opacity 0.6s ease;
}

.article-card::before {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
}

.article-card::after {
  bottom: 10px;
  right: 10px;
  border-left: none;
  border-top: none;
}

/* Card States (absolute positioning prevents layout shifts) */
.article-card.card-outgoing {
  top: -14vh;
  transform: translateX(-50%) scale(0.7);
  opacity: 0;
  z-index: 0;
}

.article-card.card-prev {
  top: 2vh;
  transform: translateX(-50%) scale(0.72);
  opacity: 0.3;
  z-index: 1;
}

.article-card.card-current {
  top: 24vh;
  transform: translateX(-50%) scale(1.2);
  opacity: 1;
  z-index: 10;
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.55),
    0 0 80px var(--accent-soft),
    inset 0 1px 0 rgba(196, 163, 116, 0.12);
  border-color: var(--accent);
  border-width: 1px;
}

.article-card.card-current::before,
.article-card.card-current::after {
  opacity: 0.7;
}

/* Animation when a freshly-arrived article first lands in the center */
.article-card.card-current.card-just-arrived {
  animation: just-arrived 4.8s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.article-card.card-just-arrived::before,
.article-card.card-just-arrived::after {
  animation: corner-flare 4.8s ease-out both;
}

@keyframes just-arrived {
  0% {
    box-shadow:
      0 25px 60px rgba(0, 0, 0, 0.55),
      0 0 0 transparent,
      inset 0 1px 0 rgba(196, 163, 116, 0.12);
    border-color: var(--accent);
  }
  35% {
    box-shadow:
      0 25px 60px rgba(0, 0, 0, 0.55),
      0 0 160px rgba(196, 163, 116, 0.55),
      inset 0 1px 0 rgba(196, 163, 116, 0.4);
    border-color: rgba(220, 195, 145, 1);
  }
  100% {
    box-shadow:
      0 25px 60px rgba(0, 0, 0, 0.55),
      0 0 80px var(--accent-soft),
      inset 0 1px 0 rgba(196, 163, 116, 0.12);
    border-color: var(--accent);
  }
}

@keyframes corner-flare {
  0%   { opacity: 0.4; }
  30%  { opacity: 1;   }
  100% { opacity: 0.7; }
}

.article-card.card-next {
  top: 46vh;
  transform: translateX(-50%) scale(0.88);
  opacity: 0.4;
  z-index: 1;
}

.article-card.card-incoming {
  top: 82vh;
  transform: translateX(-50%) scale(0.75);
  opacity: 0;
  z-index: 0;
}

.article-card.card-prev:hover,
.article-card.card-next:hover {
  opacity: 0.7 !important;
}

.article-card.card-current:hover {
  transform: translateX(-50%) scale(1.22) !important;
}

.article-text {
  font-size: 5.5vh;
  line-height: 1.6;
  margin-bottom: 0;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--text-main);
  letter-spacing: 0.05em;
  text-align: center;
  overflow: hidden;
}

/* Admin Link */
.admin-link-wrapper {
  position: absolute;
  bottom: 2vh;
  right: 2vw;
  text-align: right;
  z-index: 100;
}

.admin-link, .back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.2rem;
  letter-spacing: 0.15em;
  transition: color 0.3s, border-color 0.3s;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 2px;
}

.admin-link:hover, .back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Admin Page Specific */
body:has(.admin-container) {
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

.admin-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4rem;
  background: transparent;
  box-shadow: none;
  border-bottom: 1px solid var(--border-color);
  padding: 2rem 0;
  height: auto;
}

.admin-header .site-title {
  margin-bottom: 0;
  font-size: 2.5rem;
}

.admin-panel {
  background: linear-gradient(155deg, var(--panel-bg) 0%, #1e1a15 100%);
  border: 1px solid var(--border-color);
  padding: 3rem;
  margin-bottom: 2rem;
  border-radius: 4px;
  box-shadow: 0 12px 40px var(--shadow-color), inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.admin-panel h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  font-weight: normal;
  color: var(--text-main);
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 1rem;
  letter-spacing: 0.08em;
}

.input-group {
  display: flex;
  gap: 1rem;
}

.admin-input {
  flex: 1;
  background: var(--panel-bg-soft);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  font-size: 1.2rem;
  font-family: var(--font-main);
  border-radius: 2px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.admin-input::placeholder {
  color: var(--text-muted);
}

.admin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.admin-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 2px;
  letter-spacing: 0.1em;
}

.admin-btn:hover {
  background: var(--accent);
  color: var(--bg-color);
  box-shadow: 0 0 20px var(--accent-soft);
}

.error-msg {
  color: var(--danger);
  margin-top: 1rem;
  font-size: 1.1rem;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-item {
  border: 1px solid var(--border-soft);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  transition: border-color 0.3s, background 0.3s;
}

.admin-item:hover {
  border-color: var(--accent);
  background: rgba(196, 163, 116, 0.04);
}

.item-content {
  flex: 1;
}

.item-text {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  line-height: 1.6;
}

.item-meta {
  color: var(--text-muted);
  font-size: 1rem;
}

.delete-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 1.1rem;
  transition: all 0.3s;
  border-radius: 2px;
  letter-spacing: 0.05em;
}

.delete-btn:hover {
  background: var(--danger);
  color: var(--bg-color);
  box-shadow: 0 0 16px rgba(201, 138, 138, 0.25);
}

.hidden {
  display: none !important;
}

.loading-text,
.empty-text {
  color: var(--text-muted);
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 4rem 0;
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 900px) {
  .article-card {
    width: 90vw;
  }

  .header-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .qr-container {
    width: 14vh;
    height: 14vh;
  }

  .article-text {
    font-size: 3vh;
  }
}
