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

:root {
  --bg: #f5f0e8;
  --text: #3d2b1f;
  --text-heading: #2a1a0e;
  --accent: #8b4513;
  --accent-muted: #7a5c10;
  --text-secondary: #4a3728;
  --text-tertiary: #74604a;
  --border: #c4a882;
  --error: #8a3333;
  --link-underline: #c4a882;
  --icon-filter: sepia(40%) saturate(60%) brightness(80%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1410;
    --text: #d4c8b8;
    --text-heading: #e8ddd0;
    --accent: #c4813a;
    --accent-muted: #b89540;
    --text-secondary: #b8a898;
    --text-tertiary: #9a8a78;
    --border: #3d3228;
    --error: #d4736a;
    --link-underline: #5a4a38;
    --icon-filter: sepia(20%) saturate(40%) brightness(160%) invert(85%);
  }
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  padding: 2rem max(1rem, env(safe-area-inset-left)) 2rem max(1rem, env(safe-area-inset-right));
  touch-action: manipulation;
}

main {
  max-width: 640px;
  width: 100%;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 1.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 400;
  text-wrap: balance;
}

.tagline {
  font-style: italic;
  color: var(--accent-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

article {
  text-align: center;
}

/* Content entrance animation */
#event {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#event.visible {
  opacity: 1;
  transform: translateY(0);
}

.label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
}

#icon-container {
  margin: 0 auto 1.25rem;
  width: 120px;
  height: 120px;
}

#icon-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: var(--icon-filter);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#icon-container img.loaded {
  opacity: 1;
}

h2 {
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--text-heading);
  margin-bottom: 1rem;
  font-weight: 600;
  text-wrap: balance;
}

#summary {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

footer {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  padding-top: 1rem;
  font-variant-numeric: tabular-nums;
}

.separator {
  margin: 0 0.5rem;
}

/* Loading state animation */
#loading,
#empty,
#error {
  padding: 3rem 1rem;
  color: var(--text-tertiary);
  font-style: italic;
}

#loading p {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#error {
  color: var(--error);
}

/* Share button */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-tertiary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.share-btn:active {
  transform: scale(0.97);
}

.share-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.share-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .share-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
  }
}

/* Site credit */
.site-credit {
  max-width: 640px;
  width: 100%;
  text-align: center;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.site-credit p {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-credit a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 2px;
}

/* Focus indicators */
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Hover states gated behind pointer capability */
@media (hover: hover) and (pointer: fine) {
  a {
    transition: color 0.15s ease;
  }
  a:hover {
    color: var(--accent);
  }
}

/* Tablet breakpoint */
@media (max-width: 768px) {
  body {
    padding: 2rem 1.5rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  #icon-container {
    width: 100px;
    height: 100px;
  }
}

/* Phone breakpoint */
@media (max-width: 480px) {
  h1 {
    font-size: 1.25rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  #icon-container {
    width: 80px;
    height: 80px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
