/* Editorial reading layer shared by the bilingual Sleep Essay pages. */

html {
  scroll-behavior: smooth;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 140;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

#back-bar {
  min-height: 43px;
}

#back-bar .back-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-left: auto;
}

#back-bar .language-link {
  padding-left: 0.8rem;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

#reading-progress {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.hero {
  min-height: calc(100svh - 43px);
  padding: clamp(5.5rem, 8vw, 8rem) clamp(2rem, 5vw, 7rem);
}

.hero-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(410px, 0.88fr) minmax(520px, 1.12fr);
  gap: clamp(3.5rem, 6vw, 7rem);
  align-items: center;
  width: min(100%, 1500px);
  margin: 0 auto;
}

.hero-copy {
  min-width: 0;
}

.hero-copy h1 {
  font-size: clamp(2.75rem, 3.75vw, 3.45rem);
}

.hero-title-line {
  display: inline-block;
  white-space: nowrap;
}

.hero-title-mobile-break {
  display: none;
}

.hero .hero-sub {
  max-width: 640px;
  margin-bottom: 2.5rem;
}

.hero .hero-stats {
  flex-wrap: wrap;
  gap: 2rem clamp(1.5rem, 3vw, 3rem);
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2.6rem;
}

.hero-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(124, 226, 255, 0.35);
  border-radius: 999px;
  background: rgba(124, 226, 255, 0.08);
  color: #e6faff;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.hero-action.secondary {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-muted);
}

.hero-action:hover {
  border-color: rgba(124, 226, 255, 0.7);
  background: rgba(124, 226, 255, 0.14);
  color: #fff;
}

.editorial-intro {
  padding: 6rem 0 5rem;
  border-bottom: 1px solid var(--divider);
}

.editorial-lede {
  max-width: 720px;
  margin-bottom: 3rem;
  color: #b9c3d1;
  font-size: 1.08rem;
  line-height: 1.9;
}

.findings-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 2.5rem;
  list-style: none;
  counter-reset: sleep-findings;
}

.finding-item {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: 0.8rem;
  padding: 1.35rem 0;
  border-top: 1px solid var(--border);
  counter-increment: sleep-findings;
}

.finding-item::before {
  content: "0" counter(sleep-findings);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.finding-item h3 {
  margin-bottom: 0.45rem;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.45;
}

.finding-item p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.75;
}

.finding-item a {
  color: inherit;
  text-decoration-color: rgba(124, 226, 255, 0.4);
  text-underline-offset: 0.2em;
}

.finding-confidence {
  display: inline-block;
  margin-top: 0.7rem;
  color: #b9c3d1;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.medical-boundary {
  margin-top: 3rem;
  padding: 1.35rem 1.5rem;
  border: 1px solid rgba(255, 166, 87, 0.3);
  border-left: 3px solid var(--accent3);
  border-radius: 0 10px 10px 0;
  background: rgba(255, 166, 87, 0.045);
  color: #aeb8c6;
  font-size: 0.86rem;
  line-height: 1.8;
}

.medical-boundary strong {
  color: var(--text);
}

.medical-boundary a {
  color: #ffd2a7;
  text-decoration-color: rgba(255, 210, 167, 0.45);
  text-underline-offset: 0.2em;
}

.chapter-nav {
  position: sticky;
  top: 43px;
  z-index: 95;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.chapter-nav-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.65rem 2rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chapter-nav-label {
  display: none;
  flex: 0 0 auto;
  margin-right: 0.4rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.back-contents-link {
  display: none;
}

.chapter-link {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0.45rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #8f99a7;
  font-size: 0.76rem;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.chapter-link:hover,
.chapter-link.active {
  border-color: rgba(124, 226, 255, 0.24);
  background: rgba(124, 226, 255, 0.07);
  color: #e7faff;
}

.editorial-method {
  padding: 4.5rem 0;
  border-bottom: 1px solid var(--divider);
}

.method-card {
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 226, 255, 0.035), rgba(188, 140, 255, 0.025));
}

.method-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.65fr);
  gap: 2rem;
  align-items: start;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--border);
}

.method-card h2 {
  margin-bottom: 0.7rem;
  color: var(--text);
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.25;
}

.method-card-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.75;
}

.method-window {
  color: #c6d0de;
  font-size: 0.78rem;
  line-height: 1.75;
}

.method-window strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--accent);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.3rem;
  padding-top: 1.6rem;
}

.method-item h3 {
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.83rem;
}

.method-item p {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.pretext-lab {
  --pretext-lens-color: var(--accent);
  min-width: 0;
  scroll-margin-top: 6.9rem;
}

.pretext-invitation {
  margin-bottom: 0.8rem;
  color: color-mix(in srgb, var(--pretext-lens-color) 72%, white);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pretext-preset-list {
  display: none;
}

.is-pretext-ready .pretext-preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.pretext-preset-list button {
  min-height: 40px;
  padding: 0.45rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #8f99a7;
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}

.pretext-preset-list button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--pretext-lens-color) 50%, var(--border));
  background: color-mix(in srgb, var(--pretext-lens-color) 9%, transparent);
  color: var(--text);
}

.pretext-stage {
  position: relative;
  display: none;
  height: 460px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--pretext-lens-color) 28%, var(--border));
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--pretext-lens-color) 9%, transparent), transparent 45%),
    linear-gradient(rgba(13, 17, 23, 0.76), rgba(13, 17, 23, 0.96)),
    radial-gradient(circle, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px;
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.34),
    0 0 70px color-mix(in srgb, var(--pretext-lens-color) 8%, transparent);
  contain: layout paint;
  isolation: isolate;
}

.is-pretext-ready .pretext-stage {
  display: block;
}

.pretext-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pretext-line {
  position: absolute;
  top: 0;
  left: 0;
  color: #c5ced8;
  font-family: "Inter", "Noto Sans SC", sans-serif;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: pre;
  will-change: transform;
}

.pretext-orb {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border: 1px solid color-mix(in srgb, var(--pretext-lens-color) 65%, white 10%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.23), transparent 22%),
    radial-gradient(circle at 55% 58%, color-mix(in srgb, var(--pretext-lens-color) 34%, #111827), #11151c 72%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 0 54px color-mix(in srgb, var(--pretext-lens-color) 22%, transparent);
  color: var(--text);
  font: inherit;
  text-align: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
  will-change: transform;
}

.pretext-orb::before {
  content: "";
  position: absolute;
  inset: 10%;
  border: 1px solid color-mix(in srgb, var(--pretext-lens-color) 28%, transparent);
  border-radius: inherit;
}

.pretext-orb span,
.pretext-orb small {
  position: relative;
  z-index: 1;
}

.pretext-orb span {
  font-size: 0.88rem;
  font-weight: 720;
}

.pretext-orb small {
  max-width: 76%;
  color: color-mix(in srgb, var(--pretext-lens-color) 64%, white);
  font-size: 0.6rem;
  line-height: 1.35;
}

[data-pretext-dragging] .pretext-orb {
  cursor: grabbing;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 76px color-mix(in srgb, var(--pretext-lens-color) 36%, transparent);
}

.pretext-stage-hint {
  position: absolute;
  right: 1.25rem;
  bottom: 1rem;
  z-index: 3;
  color: #66717e;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.pretext-fallback {
  display: grid;
  gap: 0.9rem;
  padding: 1.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.8;
}

.pretext-fallback p {
  padding-left: 1rem;
  border-left: 2px solid color-mix(in srgb, var(--pretext-lens-color) 35%, var(--border));
}

.is-pretext-ready .pretext-fallback {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.pretext-a11y-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

[data-pretext-overflow] .pretext-stage::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 84px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}

.pretext-preset-list button:focus-visible,
.pretext-orb:focus-visible {
  outline: 2px solid var(--pretext-lens-color);
  outline-offset: 3px;
}

.section {
  scroll-margin-top: 6.9rem;
}

.section-heading-anchor {
  color: inherit;
  text-decoration: none;
}

.section-heading-anchor:hover::after {
  content: " #";
  color: var(--accent);
  font-size: 0.72em;
}

.event-chip,
.scatter-chip {
  min-height: 44px;
}

.event-chip:focus-visible,
.scatter-chip:focus-visible,
.hero-action:focus-visible,
.chapter-link:focus-visible,
#back-bar a:focus-visible,
.section-heading-anchor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .method-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .hero-shell {
    grid-template-columns: 1fr;
    gap: 4rem;
    width: min(100%, 900px);
  }

  .hero-copy {
    max-width: 720px;
  }
}

@media (max-width: 768px) {
  .hero {
    min-height: auto;
    padding: 5rem 1.5rem 4.5rem;
  }

  .hero-shell {
    gap: 3.5rem;
  }

  .hero-copy h1 {
    font-size: clamp(2.5rem, 11vw, 3rem);
  }

  .hero-title-line {
    display: inline;
    white-space: normal;
  }

  .hero-title-mobile-break {
    display: initial;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-top: 2.2rem;
  }

  .hero-action {
    text-align: center;
  }

  .editorial-intro {
    padding: 4.5rem 0 4rem;
  }

  .findings-list {
    grid-template-columns: 1fr;
  }

  .finding-item {
    grid-template-columns: 2.3rem minmax(0, 1fr);
  }

  .chapter-nav-inner {
    padding: 0.55rem 1.5rem;
  }

  .chapter-nav-label {
    display: inline-flex;
    position: sticky;
    left: -1.5rem;
    z-index: 2;
    padding: 0.45rem 0.7rem 0.45rem 1.5rem;
    background: linear-gradient(90deg, rgba(13, 17, 23, 1) 75%, rgba(13, 17, 23, 0));
  }

  .back-contents-link {
    display: inline-flex;
  }

  .method-card {
    padding: 1.4rem;
  }

  .method-card-header,
  .method-grid {
    grid-template-columns: 1fr;
  }

  .pretext-stage {
    height: 430px;
    border-radius: 14px;
  }

  .pretext-stage-hint {
    right: auto;
    left: 1.2rem;
  }

  #back-bar {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  #back-bar .back-title {
    display: none;
  }
}

@media (max-width: 420px) {
  .hero-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
