:root {
  --color-bg: #FFFFFF;
  --color-surface: #FFFFFF;
  --color-text-primary: #1F2933;
  --color-text-secondary: #4B5563;
  --color-border: #E8E8E8;
  --color-primary: #5BB98C;
  --color-primary-pressed: #30A46C;
  /* iOS overlay button palette (light) */
  --overlay-btn-bg: rgba(255, 255, 255, 0.92);
  --overlay-btn-fg: #1F2933;
  --overlay-btn-border: rgba(232, 232, 232, 0.6);
  --overlay-btn-shadow-opacity: 0.18;

  /* Reusable layout gaps */
  --overlay-action-left-gap: var(--space-md);
  --overlay-action-gap-to-title: var(--space-sm);

  /* Overlay paddings used in shared discovery */
  --overlay-padding-x: 28px;
  --overlay-padding-bottom: 28px;

  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --radius-md: 12px;
  --radius-lg: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #080A15;
    --color-surface: #0E1221;
    --color-text-primary: #FFFFFF;
    --color-text-secondary: rgba(255, 255, 255, 0.85);
    --color-border: #2E2E2E;
    --color-primary: #236E4A;
    --color-primary-pressed: #1B543A;
    /* iOS overlay button palette (dark) */
    --overlay-btn-bg: rgba(0, 0, 0, 0.6);
    --overlay-btn-fg: #FFFFFF;
    --overlay-btn-border: rgba(255, 255, 255, 0.2);
    --overlay-btn-shadow-opacity: 0.3;
  }
}

html,
body {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

.brand-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.btn-primary {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
}

.btn-primary:hover {
  background: var(--color-primary-pressed);
}

/* Discovery page */
.discovery-root {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

.discovery-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}


.placeholder {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-secondary);
}

/* Loading animation */
.loading-center {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.loading-logo {
  width: 120px;
  height: auto;
  animation: logo-pulse 1.6s ease-in-out infinite;
}

@keyframes logo-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-logo {
    animation: none;
  }
}

/* Sticky header for shared pages */
.share-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  background: color-mix(in srgb, var(--color-surface), transparent 8%);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: saturate(1.2) blur(8px);
}

.share-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text-primary);
}

.share-header .brand img {
  height: 28px;
  width: auto;
  display: block;
}

.share-header .brand span {
  font-weight: 700;
}

.share-header .cta {
  text-decoration: none;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
}

.share-header .cta:hover {
  background: var(--color-primary-pressed);
}

/* Ensure content clears the 56px fixed header (64px = header + extra breathing room) */
main.with-sticky-header,
.with-sticky-header {
  padding-top: 64px !important;
}

.loading-with-header {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
}

/* Hero header overlay (match iOS look) */
.hero-image-wrapper {
  position: relative;
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  /* allow image taps */
}

.hero-overlay-gradient {
  background: linear-gradient(to top,
      rgba(8, 10, 21, 0.94) 0%,
      rgba(8, 10, 21, 0.88) 40%,
      rgba(8, 10, 21, 0.70) 70%,
      rgba(8, 10, 21, 0.40) 85%,
      rgba(8, 10, 21, 0.00) 100%);
  padding: var(--overlay-action-gap-to-title) var(--overlay-padding-x) var(--overlay-padding-bottom) var(--overlay-padding-x);
}

.hero-overlay-content {
  color: #fff;
  text-align: center;
  max-width: 960px;
  margin: 0 auto;
}

.hero-title {
  font-size: 30px;
  font-weight: 800;
  margin: 0 0 6px;
}

.hero-submeta {
  font-size: 16px;
  opacity: 0.92;
  margin-bottom: 10px;
}

.hero-short {
  font-size: 15px;
  opacity: 0.95;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-left: var(--overlay-action-left-gap);
  margin-bottom: 0;
  padding: 0;
}

.hero-action {
  pointer-events: auto;
  background: var(--overlay-btn-bg);
  color: var(--overlay-btn-fg);
  border: 1px solid var(--overlay-btn-border);
  border-radius: 999px;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, var(--overlay-btn-shadow-opacity));
  backdrop-filter: saturate(1.2) blur(8px);
  cursor: pointer;
}

.hero-action:hover {
  filter: brightness(1.05);
}

.hero-action svg {
  width: 28px;
  height: 28px;
}

/* Full description */
.discovery-body {
  padding: 0 var(--space-lg) var(--space-xl);
}

.discovery-description {
  color: var(--color-text-secondary);
  font-size: 1rem;
  line-height: 1.55;
  white-space: normal;
}

.discovery-description p {
  margin: 0 0 1em;
}

.discovery-description a {
  color: var(--color-primary);
  text-decoration: underline;
}

.discovery-description h1,
.discovery-description h2,
.discovery-description h3,
.discovery-description h4,
.discovery-description h5,
.discovery-description h6 {
  color: var(--color-text-primary);
  margin: 1.25em 0 .5em;
  line-height: 1.25;
}

.discovery-description h1 {
  font-size: 1.6rem;
}

.discovery-description h2 {
  font-size: 1.4rem;
}

.discovery-description h3 {
  font-size: 1.2rem;
}

.discovery-description ul,
.discovery-description ol {
  padding-left: 1.2em;
  margin: 0 0 1em;
}

.discovery-description code {
  background: rgba(127, 127, 127, 0.15);
  padding: 0 .25em;
  border-radius: 4px;
  color: inherit;
}

/* Fullscreen image viewer */
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.image-viewer.open {
  display: flex;
}

.image-viewer img {
  max-width: 95vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 12px;
}

.image-viewer .close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.image-viewer .close-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}