:root {
  --sepia: #D9C9A6;
  --parchment: #F3E9D2;
  --deep-ink: #2C1A10;
  --arcane-gold: #F8D774;
  --spell-blue: #5AA2FF;
  --enchanted-emerald: #3ECF82;
  --mystery-violet: #A67EFF;
  --shadow-soft: rgba(44, 26, 16, 0.15);
  --shadow-medium: rgba(44, 26, 16, 0.25);
}

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

body {
  font-family: 'Crimson Text', Georgia, serif;
  background: 
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #F3E9D2 0%, #D9C9A6 50%, #C9B896 100%);
  background-blend-mode: overlay;
  min-height: 100vh;
  color: var(--deep-ink);
  overflow-x: hidden;
}

#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.magic-newspaper {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding-bottom: 100px;
}

/* Masthead */
.masthead {
  text-align: center;
  padding: 40px 20px 30px;
  border-bottom: 2px solid var(--deep-ink);
  margin-bottom: 20px;
  position: relative;
  background: linear-gradient(180deg, rgba(248, 215, 116, 0.1) 0%, transparent 100%);
}

.masthead-flourish {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  color: var(--arcane-gold);
  animation: floatGently 4s ease-in-out infinite;
}

.masthead-flourish.left { left: 20px; }
.masthead-flourish.right { right: 20px; transform: translateY(-50%) scaleX(-1); }

.masthead-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--deep-ink) 0%, #4a3020 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px var(--shadow-soft);
  animation: shimmerTitle 3s ease-in-out infinite;
  position: relative;
}

@keyframes shimmerTitle {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.1); }
}

.masthead-subtitle {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--deep-ink);
  opacity: 0.8;
  margin-top: 8px;
}

.masthead-date {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  margin-top: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Section Navigation */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 15px 20px;
  background: linear-gradient(180deg, rgba(44, 26, 16, 0.05) 0%, transparent 100%);
  border-bottom: 1px solid rgba(44, 26, 16, 0.1);
}

.section-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(180deg, var(--parchment) 0%, var(--sepia) 100%);
  border: 1px solid rgba(44, 26, 16, 0.2);
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  color: var(--deep-ink);
  transition: all 0.4s ease;
  box-shadow: 0 2px 8px var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.section-tab::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, var(--accent-color) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.section-tab:hover::before,
.section-tab.active::before {
  opacity: 0.2;
}

.section-tab.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 15px rgba(248, 215, 116, 0.3);
}

.tab-rune {
  font-size: 1.1rem;
  transition: all 0.4s ease;
}

.section-tab:hover .tab-rune,
.section-tab.active .tab-rune {
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-color);
  animation: runeFlare 0.5s ease;
}

@keyframes runeFlare {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.tab-name {
  position: relative;
  z-index: 1;
}

/* Summoning Glyph */
.summoning-glyph {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--parchment) 0%, var(--sepia) 100%);
  border: 2px solid var(--arcane-gold);
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 0 20px rgba(248, 215, 116, 0.3);
  transition: all 0.4s ease;
}

.summoning-glyph:hover {
  box-shadow: 0 0 30px rgba(248, 215, 116, 0.5);
  transform: scale(1.05);
}

.glyph-outer,
.glyph-inner {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--arcane-gold);
}

.glyph-outer {
  inset: 4px;
  animation: rotateGlyph 20s linear infinite;
}

.glyph-inner {
  inset: 12px;
  animation: rotateGlyph 15s linear infinite reverse;
}

.glyph-runes {
  position: absolute;
  inset: 0;
  animation: rotateGlyph 10s linear infinite;
}

.glyph-runes span {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 0.7rem;
  color: var(--arcane-gold);
  transform-origin: center;
}

.glyph-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--deep-ink);
}

@keyframes rotateGlyph {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.summoning-glyph.active {
  animation: glyphActivate 1.5s ease;
}

.summoning-glyph.active .glyph-runes {
  animation: rotateGlyph 0.5s linear infinite;
}

@keyframes glyphActivate {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(248, 215, 116, 0.3); }
  50% { transform: scale(1.2); box-shadow: 0 0 50px rgba(248, 215, 116, 0.8); }
  100% { transform: scale(1); box-shadow: 0 0 20px rgba(248, 215, 116, 0.3); }
}

/* Ink Wave */
.ink-wave {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.ink-wave-inner {
  position: absolute;
  top: -100%;
  left: -10%;
  right: -10%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(248, 215, 116, 0.3) 0%, rgba(248, 215, 116, 0) 70%);
  animation: inkWaveDown 0.8s ease-out forwards;
}

@keyframes inkWaveDown {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

/* Articles Grid */
.newspaper-content {
  padding: 30px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.newspaper-content.refreshing .article-card {
  animation: scrambleReform 1.5s ease-out;
}

@keyframes scrambleReform {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  30% { opacity: 0; transform: translateY(-20px) rotate(5deg); }
  70% { opacity: 0; transform: translateY(20px) rotate(-5deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0deg); }
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 30px;
}

/* Article Cards */
.article-card {
  background: linear-gradient(145deg, var(--parchment) 0%, var(--sepia) 100%);
  border-radius: 4px;
  padding: 20px;
  position: relative;
  box-shadow: 
    0 4px 20px var(--shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: all 0.5s ease;
  opacity: 0;
  transform: translateY(30px) rotate(1deg);
  animation: floatCard 6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.article-card.visible {
  opacity: 1;
  transform: translateY(0) rotate(0deg);
}

@keyframes floatCard {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(0.5deg); }
}

.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--arcane-gold), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.article-card:hover::before {
  opacity: 1;
}

.article-card:hover {
  box-shadow: 
    0 8px 40px var(--shadow-medium),
    0 0 30px rgba(248, 215, 116, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-5px);
}

.article-card.is-new::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 6px;
  background: linear-gradient(45deg, var(--arcane-gold), var(--spell-blue), var(--arcane-gold));
  z-index: -1;
  animation: newArticleGlow 3s ease-in-out infinite;
}

@keyframes newArticleGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* Living Photos */
.living-photo {
  margin-bottom: 15px;
  perspective: 1000px;
}

.photo-frame {
  position: relative;
  height: 180px;
  border-radius: 4px;
  overflow: hidden;
  border: 3px solid #8B7355;
  box-shadow: 
    inset 0 0 20px rgba(0, 0, 0, 0.3),
    0 4px 15px var(--shadow-medium);
  background: linear-gradient(135deg, #5c4a3a 0%, #3d2e22 100%);
}

.photo-content {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.photo-layer {
  position: absolute;
  inset: 0;
  transition: transform 0.6s ease;
}

.photo-layer.layer-1 {
  background: 
    radial-gradient(circle at 30% 40%, rgba(248, 215, 116, 0.4) 0%, transparent 50%),
    linear-gradient(135deg, #4a3a2a 0%, #2d1f14 100%);
  animation: layerDrift1 8s ease-in-out infinite;
}

.photo-layer.layer-2 {
  background: 
    radial-gradient(circle at 70% 60%, rgba(90, 162, 255, 0.3) 0%, transparent 40%);
  animation: layerDrift2 6s ease-in-out infinite;
}

.photo-layer.layer-3 {
  background: 
    radial-gradient(circle at 50% 50%, rgba(62, 207, 130, 0.2) 0%, transparent 60%);
  animation: layerDrift3 10s ease-in-out infinite;
}

@keyframes layerDrift1 {
  0%, 100% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(10px) translateY(-5px); }
}

@keyframes layerDrift2 {
  0%, 100% { transform: translateX(0) translateY(0) scale(1); }
  50% { transform: translateX(-8px) translateY(8px) scale(1.05); }
}

@keyframes layerDrift3 {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(2deg); }
}

.living-photo.is-aware .photo-layer {
  animation-duration: 2s;
}

.photo-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  color: var(--arcane-gold);
  font-size: 0.8rem;
  animation: sparkleFloat 1s ease-out forwards;
}

@keyframes sparkleFloat {
  0% { opacity: 0; transform: scale(0); }
  50% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-20px) scale(0.5); }
}

.rune-border {
  position: absolute;
  inset: -4px;
  border: 2px solid var(--arcane-gold);
  border-radius: 6px;
  animation: runeBorderPulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes runeBorderPulse {
  0%, 100% { opacity: 0.3; box-shadow: 0 0 10px var(--arcane-gold); }
  50% { opacity: 0.8; box-shadow: 0 0 20px var(--arcane-gold); }
}

/* Floating Headlines */
.floating-headline {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 10px;
  cursor: pointer;
  text-shadow: 0 2px 4px var(--shadow-soft);
  transition: all 0.4s ease;
  display: inline-block;
}

.floating-headline:hover {
  color: var(--deep-ink);
  text-shadow: 
    0 2px 4px var(--shadow-soft),
    0 0 20px rgba(248, 215, 116, 0.4);
}

.floating-headline .capital {
  display: inline-block;
  transition: all 0.3s ease;
}

.floating-headline:hover .capital {
  animation: capitalFlourish 0.5s ease forwards;
}

@keyframes capitalFlourish {
  0% { transform: scale(1); }
  50% { transform: scale(1.1) rotate(-3deg); color: var(--arcane-gold); }
  100% { transform: scale(1); }
}

/* Topic Chips */
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.topic-chip {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(135deg, var(--sepia) 0%, #c9b896 100%);
  border: 1px solid rgba(44, 26, 16, 0.3);
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: 'Crimson Text', serif;
  cursor: pointer;
  transition: all 0.4s ease;
  animation: chipOrbit 8s ease-in-out infinite;
}

.topic-chip:nth-child(2) { animation-delay: 0.5s; }
.topic-chip:nth-child(3) { animation-delay: 1s; }

@keyframes chipOrbit {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.topic-chip:hover {
  background: var(--arcane-gold);
  border-color: var(--deep-ink);
  box-shadow: 0 0 10px rgba(248, 215, 116, 0.5);
}

.topic-chip.spinning {
  animation: chipSpin 0.5s ease;
}

@keyframes chipSpin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

.topic-chip.active {
  background: var(--arcane-gold);
  box-shadow: 0 0 15px rgba(248, 215, 116, 0.6);
}

/* Article Intro */
.article-intro {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--deep-ink);
  opacity: 0.9;
}

.drop-cap {
  float: left;
  font-family: 'Cinzel', serif;
  font-size: 3rem;
  line-height: 0.8;
  margin-right: 8px;
  margin-top: 4px;
  color: var(--deep-ink);
  text-shadow: 2px 2px 0 rgba(248, 215, 116, 0.3);
}

.drop-cap.large {
  font-size: 4.5rem;
  margin-right: 12px;
}

/* Article View */
.article-view {
  position: fixed;
  inset: 0;
  background: rgba(44, 26, 16, 0.95);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  overflow-y: auto;
  padding: 20px;
}

.article-view.visible {
  opacity: 1;
}

.article-view-content {
  background: 
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--parchment) 0%, var(--sepia) 100%);
  background-blend-mode: overlay;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  padding: 40px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(50px) rotateX(5deg);
  transition: transform 0.5s ease;
}

.article-view.visible .article-view-content {
  transform: translateY(0) rotateX(0deg);
}

.floating-symbols {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-symbol {
  position: absolute;
  font-size: 1.5rem;
  color: var(--arcane-gold);
  opacity: 0.15;
  animation: symbolDrift 15s ease-in-out infinite;
}

@keyframes symbolDrift {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.1; }
  50% { transform: translateY(-30px) rotate(180deg); opacity: 0.25; }
}

.article-header {
  margin-bottom: 30px;
}

.article-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin-top: 15px;
  animation: quillWrite 1s ease-out;
}

@keyframes quillWrite {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.article-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--deep-ink), transparent);
  margin: 30px 0;
  position: relative;
}

.article-divider::before {
  content: '❧';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--parchment);
  padding: 0 15px;
  color: var(--arcane-gold);
}

.article-body {
  font-size: 1.1rem;
  line-height: 1.8;
}

.article-body p {
  margin-bottom: 1.5em;
  animation: fadeInUp 0.6s ease-out backwards;
}

.article-body p:nth-child(1) { animation-delay: 0.2s; }
.article-body p:nth-child(2) { animation-delay: 0.4s; }
.article-body p:nth-child(3) { animation-delay: 0.6s; }
.article-body p:nth-child(4) { animation-delay: 0.8s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.magical-quote {
  font-style: italic;
  font-size: 1.2rem;
  padding: 20px 30px;
  margin: 30px 0;
  border-left: 3px solid var(--arcane-gold);
  background: linear-gradient(90deg, rgba(248, 215, 116, 0.1) 0%, transparent 100%);
  position: relative;
}

.magical-quote::before,
.magical-quote::after {
  content: '✦';
  position: absolute;
  color: var(--arcane-gold);
  opacity: 0.5;
}

.magical-quote::before { top: 10px; right: 20px; }
.magical-quote::after { bottom: 10px; right: 40px; }

.bookmark-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 40px auto 0;
  padding: 15px 30px;
  background: linear-gradient(180deg, var(--sepia) 0%, #c9b896 100%);
  border: 2px solid var(--deep-ink);
  border-radius: 4px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.4s ease;
  box-shadow: 0 4px 15px var(--shadow-soft);
}

.bookmark-button:hover {
  background: var(--arcane-gold);
  box-shadow: 0 0 20px rgba(248, 215, 116, 0.5);
  transform: translateY(-2px);
}

.bookmark-rune {
  font-size: 1.2rem;
  animation: runeFloat 2s ease-in-out infinite;
}

@keyframes runeFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Footer */
.newspaper-footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 2px solid var(--deep-ink);
  margin-top: 60px;
  background: linear-gradient(0deg, rgba(44, 26, 16, 0.05) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.footer-flourish {
  color: var(--arcane-gold);
  font-size: 1.2rem;
  animation: floatGently 3s ease-in-out infinite;
}

.newspaper-footer p {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 0.95rem;
}

.newspaper-footer a {
  color: var(--deep-ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--arcane-gold);
  transition: all 0.3s ease;
}

.newspaper-footer a:hover {
  color: var(--arcane-gold);
  border-bottom-style: solid;
}

@keyframes floatGently {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Responsive */
@media (max-width: 768px) {
  .masthead-flourish { display: none; }
  
  .section-nav {
    gap: 6px;
    padding: 10px;
  }
  
  .section-tab {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  
  .tab-name {
    display: none;
  }
  
  .tab-rune {
    font-size: 1.3rem;
  }
  
  .summoning-glyph {
    width: 50px;
    height: 50px;
    top: 15px;
    right: 15px;
  }
  
  .articles-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .article-view-content {
    padding: 25px;
  }
  
  .floating-headline {
    font-size: 1.1rem;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--sepia);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--deep-ink) 0%, #5c4a3a 100%);
  border-radius: 5px;
  border: 2px solid var(--sepia);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--deep-ink);
}