/* tooltip */
    #star-tooltip {
      position: fixed;
      background: rgba(7, 9, 26, 0.92);
      border: 1px solid var(--gold-dim);
      color: var(--text);
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      padding: 5px 10px;
      border-radius: 1px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.12s;
      z-index: 100;
      letter-spacing: 0.04em;
      white-space: nowrap;
    }
    #star-tooltip.visible { opacity: 1; }

   /* star popover: confirmation step before simbad redirect */
    #star-popover {
      position: fixed;
      background: rgba(7, 9, 26, 0.96);
      border: 1px solid var(--panel-border);
      padding: 12px 16px;
      z-index: 150;
      min-width: 180px;
      max-width: 260px;
      
      /* 1. When hidden, it shouldn't block clicks */
      opacity: 0;
      pointer-events: none; 
      
      /* 2. Wait 0.4 seconds before fading out and disabling clicks */
      transition: opacity 0.2s ease 0.4s, pointer-events 0s linear 0.4s;
    }

    #star-popover.visible { 
      /* 3. Appear instantly with NO delay when the class is added */
      opacity: 1; 
      pointer-events: all;
      transition: opacity 0.15s ease 0s, pointer-events 0s linear 0s;
    }
    
    /* 4. The Magic Trick: Keep it visible if the mouse makes it to the popover! */
    #star-popover:hover {
      opacity: 1;
      pointer-events: all;
      transition: opacity 0.15s ease 0s, pointer-events 0s linear 0s;
    }

    #star-popover-name {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      letter-spacing: 0.04em;
      color: var(--text);
      margin-bottom: 10px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #star-popover-btn {
      display: block;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.1em;
      color: var(--gold);
      text-decoration: none;
      border: 1px solid var(--gold-dim);
      padding: 5px 10px;
      text-align: center;
      transition: opacity 0.15s;
    }

    #star-popover-btn:hover {
      opacity: 0.75;
    }

    /* modal */
    #object-modal {
      position: fixed;
      inset: 0;
      background: rgba(5, 7, 18, 0.88);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      z-index: 200;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.28s;
    }
    #object-modal.visible { opacity: 1; pointer-events: all; }

    .modal-inner {
      max-width: 580px;
      width: calc(100% - 40px);
      max-height: 85vh;
      background: rgba(9, 12, 28, 0.98);
      border: 1px solid var(--panel-border);
      padding: 44px 48px;
      position: relative;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    .modal-type {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      letter-spacing: 0.18em;
      color: var(--gold);
      text-transform: uppercase;
      margin-bottom: 10px;
    }

    .modal-name {
      font-family: 'EB Garamond', serif;
      font-size: 28px;
      font-weight: 400;
      line-height: 1.2;
      margin-bottom: 22px;
      color: var(--text);
    }

    .modal-body {
      font-family: 'Spectral', serif;
      font-size: 15.5px;
      line-height: 1.78;
      color: var(--text-dim);
      margin-bottom: 28px;
    }

    .modal-simbad {
      display: inline-block;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11.5px;
      color: var(--gold);
      text-decoration: none;
      border: 1px solid var(--gold-dim);
      padding: 7px 16px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      transition: background 0.18s, color 0.18s;
    }
    .modal-simbad:hover { background: var(--gold); color: var(--bg); }

    .modal-close {
      position: absolute;
      top: 16px;
      right: 20px;
      background: none;
      border: none;
      color: var(--text-dim);
      font-size: 18px;
      cursor: pointer;
      font-family: 'EB Garamond', serif;
      line-height: 1;
      transition: color 0.15s;
    }
    .modal-close:hover { color: var(--text); }

    /* modal object image — DSS sky cutout or provided photo */
    #modal-img-wrap {
      width: 100%;
      aspect-ratio: 480 / 280;
      background: rgba(5, 7, 18, 0.8);
      border: 1px solid var(--panel-border);
      overflow: hidden;
      margin-bottom: 28px;
    }

    #modal-img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      opacity: 0;
      transition: opacity 0.4s ease;
    }

    #modal-img-loading {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.08em;
      color: rgba(226, 221, 212, 0.28);
    }
    /* sections */
    .section {
      background: var(--panel);
      border-top: 1px solid var(--panel-border);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      padding: 100px 52px;
    }

    .section-inner {
      max-width: 880px;
      margin: 0 auto;
    }

    /* sr-only: visually hide text but keep it for seo and screen readers */
    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0,0,0,0);
      white-space: nowrap;
    }

    /* ::before = mono label pulled from data-label; ::after = decorative rule */
    .section-heading {
      font-family: 'EB Garamond', serif;
      font-size: clamp(32px, 5vw, 48px);
      font-weight: 400;
      line-height: 1.1;
      color: var(--text);
      margin-bottom: 52px;
      letter-spacing: -0.01em;
      position: sticky;
      top: 20px;
      background: var(--panel);
      z-index: 10;
      padding: 10px 0 0;
    }
    .section-heading::before {
      content: attr(data-label);
      display: block;
      font-family: 'JetBrains Mono', monospace;
      font-size: 18px;
      letter-spacing: 0.28em;
      color: var(--gold);
      text-transform: uppercase;
      margin-bottom: 10px;
    }
    .section-heading::after {
      content: '';
      display: block;
      height: 1px;
      background: var(--panel-border);
      margin-bottom: 14px;
    }

    /* about */
    .about-footnote {
      margin-top: 28px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11.5px;
      color: var(--text-dim);
      opacity: 0.6;
      line-height: 1.6;
    }
    .about-grid {
      display: grid;
      grid-template-columns: 1.1fr 0.9fr;
      gap: 64px;
      align-items: start;
    }

    .about-text .about-lead {
      font-family: 'EB Garamond', serif;
      font-size: 22px;
      line-height: 1.58;
      color: var(--text);
      margin-bottom: 24px;
    }

    .about-text p {
      font-size: 16px;
      color: var(--text-dim);
      margin-bottom: 18px;
      line-height: 1.75;
    }

    .about-meta {
      display: flex;
      flex-direction: column;
      gap: 28px;
    }

    .meta-item {
      border-left: 1px solid var(--gold-dim);
      padding-left: 20px;
    }

    .meta-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.16em;
      color: var(--gold);
      text-transform: uppercase;
      margin-bottom: 6px;
    }

    .meta-value {
      font-size: 14.5px;
      color: var(--text-dim);
      line-height: 1.55;
    }

    .meta-value a {
      color: var(--blue);
      text-decoration: none;
    }
    .meta-value a:hover { text-decoration: underline; }

    /* research */
    .research-cards {
      display: flex;
      flex-direction: column;
      gap: 28px;
    }

    .research-card {
      border: 1px solid var(--panel-border);
      padding: 34px 36px;
      transition: opacity 0.25s, transform 0.25s ease;
      position: relative;
    }
    .research-card::after {
      content: '';
      position: absolute;
      inset: 0;
      border: 1px solid rgba(196, 162, 88, 0.4);
      box-shadow: 0 20px 40px rgba(0,0,0,0.35);
      opacity: 0;
      transition: opacity 0.25s;
      pointer-events: none;
    }
    .research-card:hover {
      transform: translateY(-6px);
    }
    .research-card:hover::after {
      opacity: 1;
    }

    .card-id {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.18em;
      color: var(--gold);
      text-transform: uppercase;
      margin-bottom: 13px;
    }

    .card-title {
      font-family: 'EB Garamond', serif;
      font-size: 22px;
      font-weight: 400;
      margin-bottom: 14px;
      color: var(--text);
      line-height: 1.3;
    }

    .research-intro {
      font-family: 'Spectral', serif;
      font-size: 17px;
      font-style: italic;
      color: var(--text-dim);
      line-height: 1.75;
      max-width: 640px;
      margin-bottom: 40px;
      border-left: 2px solid var(--gold-dim);
      padding-left: 20px;
    }

    .card-body {
      font-size: 15px;
      line-height: 1.78;
      color: var(--text-dim);
      margin-bottom: 22px;
    }

    .card-summary {
      font-family: 'Spectral', serif;
      font-size: 15px;
      line-height: 1.78;
      color: var(--text-dim);
      margin-bottom: 18px;
    }

    .card-expand {
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.28s ease-out;
    }

    .card-toggle {
      display: inline-block;
      -webkit-appearance: none;
      appearance: none;
      background: none;
      border: none;
      border-bottom: 1px solid var(--gold);
      border-radius: 0;
      padding: 0 0 1px 0;
      margin-bottom: 20px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.12em;
      color: var(--gold);
      text-transform: uppercase;
      cursor: pointer;
      opacity: 0.80;
      transition: opacity 0.18s;
      line-height: normal;
    }
    .card-toggle:hover { opacity: 1; }

    /* suppress hover lift when card is expanded */
    .research-card.card-open {
      transform: none;
      border-left: 2px solid rgba(196, 162, 88, 0.3);
    }
    .research-card.card-open::after {
      opacity: 0;
    }

    .card-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .tag {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.1em;
      color: var(--blue);
      border: 1px solid rgba(91, 138, 181, 0.28);
      padding: 3px 10px;
      text-transform: uppercase;
    }

    .card-link {
      display: inline-block;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.12em;
      color: var(--gold);
      text-decoration: none;
      text-transform: uppercase;
      border-bottom: 1px solid var(--gold);
      padding-bottom: 1px;
      transition: opacity 0.18s;
      margin-bottom: 20px;
      opacity: 0.80;
    }
    .card-link:hover { opacity: 1; }

    /* writing */
    .writing-intro {
      font-size: 15.5px;
      color: var(--text-dim);
      line-height: 1.75;
      max-width: 600px;
      margin-bottom: 36px;
    }

    .writing-list {
      display: flex;
      flex-direction: column;
      gap: 0;
    }

    .writing-item {
      display: grid;
      grid-template-columns: 200px 1fr;
      gap: 24px;
      padding: 28px 0;
      border-bottom: 1px solid rgba(196, 162, 88, 0.1);
      opacity: 0.88;
      transition: opacity 0.18s;
    }
    .writing-item:first-child { border-top: 1px solid rgba(196, 162, 88, 0.1); }
    .writing-item:hover { opacity: 1; }

    .writing-meta {
      display: flex;
      flex-direction: column;
      gap: 5px;
      padding-top: 3px;
    }

    .writing-venue {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.15em;
      color: var(--gold);
      text-transform: uppercase;
    }

    .writing-date {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.08em;
      color: var(--text-dim);
    }

    .writing-content h3 {
      font-family: 'EB Garamond', serif;
      font-size: 20px;
      font-weight: 400;
      margin-bottom: 8px;
      line-height: 1.3;
    }

    .writing-content h3 a {
      color: var(--text);
      text-decoration: none;
      border-bottom: 1px solid rgba(226, 221, 212, 0.18);
      transition: opacity 0.18s;
    }
    .writing-content h3 a:hover { opacity: 0.75; }

    .writing-content p {
      font-size: 14.5px;
      color: var(--text-dim);
      line-height: 1.65;
    }

    @media (max-width: 740px) {
      .writing-item { grid-template-columns: 1fr; gap: 8px; }
    }

    /* mobile sticky heading must clear the fixed nav bar (~57px) */
    @media (max-width: 740px) {
      .section-heading { top: 60px; }
    }

    /* highlights */
    .highlights-table {
      display: flex;
      flex-direction: column;
      gap: 0;
    }

    .highlights-row {
      display: grid;
      grid-template-columns: 140px 1fr;
      gap: 24px;
      padding: 24px 0;
      border-bottom: 1px solid rgba(196, 162, 88, 0.1);
    }

    .highlights-year {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12.5px;
      color: var(--gold);
      padding-top: 3px;
      letter-spacing: 0.05em;
    }

    .highlights-item h4 {
      font-family: 'EB Garamond', serif;
      font-size: 18.5px;
      font-weight: 400;
      margin-bottom: 5px;
      color: var(--text);
    }

    .highlights-item p {
      font-size: 14.5px;
      color: var(--text-dim);
      line-height: 1.6;
    }

    .highlights-cta {
      margin-top: 44px;
      display: inline-flex;
      align-items: center;
      gap: 10px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11.5px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--gold);
      text-decoration: none;
      border: 1px solid var(--gold-dim);
      padding: 11px 22px;
      transition: background 0.18s, color 0.18s;
    }
    .highlights-cta:hover { background: var(--gold); color: var(--bg); }

    /* footer */
    footer {
      background: rgba(5, 7, 18, 0.96);
      border-top: 1px solid var(--panel-border);
      padding: 44px 52px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: relative;
      z-index: 1;
    }

    .footer-left {
      font-family: 'EB Garamond', serif;
      font-size: 14px;
      color: var(--text-dim);
      font-style: italic;
    }

    .footer-links {
      display: flex;
      gap: 28px;
    }

    .footer-links a {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11.5px;
      letter-spacing: 0.12em;
      color: var(--text-dim);
      text-decoration: none;
      text-transform: uppercase;
      transition: color 0.18s;
    }
    .footer-links a:hover { color: var(--gold); }
    .footer-cssda img { width: 32px; height: 32px; }

    /* back to top */
    #back-to-top {
      position: fixed;
      bottom: 32px;
      right: 32px;
      z-index: 300;
      width: 40px;
      height: 40px;
      background: var(--panel);
      border: 1px solid var(--panel-border);
      color: var(--gold);
      font-size: 18px;
      cursor: pointer;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease, filter 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    #back-to-top.visible {
      opacity: 1;
      pointer-events: auto;
    }
    #back-to-top:hover {
      filter: brightness(1.4);
    }

    /* cepheid simulation */
    #cepheid-sim {
      position: relative;
      width: 100%;
      height: 115vh;
      background: #000;
      overflow: hidden;
      isolation: isolate;
    }
    #sim-stage {
      position: absolute;
      inset: 0;
      z-index: 1;
    }
    #simCanvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      transition: opacity 1.2s;
    }
    #sim-info {
      position: absolute;
      top: 2.5rem;
      left: 2.5rem;
      max-width: 420px;
      z-index: 20;
      pointer-events: none;
    }
    .sim-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.22em;
      color: var(--gold);
      text-transform: uppercase;
      margin: 0 0 10px;
    }
    .sim-title {
      font-family: 'EB Garamond', serif;
      font-size: clamp(22px, 3vw, 34px);
      font-weight: 400;
      color: var(--text);
      margin: 0 0 10px;
      line-height: 1.15;
    }
    .sim-rule {
      height: 1px;
      background: var(--panel-border);
      margin-bottom: 14px;
    }
    .sim-body {
      font-family: 'Spectral', serif;
      font-style: italic;
      font-size: 14.5px;
      color: var(--text-dim);
      line-height: 1.72;
      margin: 0;
    }
    .sim-cite {
      color: var(--blue);
      text-decoration: none;
      border-bottom: 1px solid rgba(120,165,210,0.3);
      pointer-events: auto;
    }
    #hud-table {
      position: absolute;
      top: 2.5rem;
      right: 2.5rem;
      z-index: 20;
      pointer-events: auto;
      flex-shrink: 0;
      background: rgba(7,9,26,0.82);
      backdrop-filter: blur(10px);
      border: 1px solid var(--panel-border);
      border-radius: 0.75rem;
      padding: 1.25rem 1.5rem;
      width: 250px;
    }
    .hud-inner {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      line-height: 1;
    }
    .hud-row {
      display: flex;
      justify-content: space-between;
      padding: 0.38rem 0;
      border-bottom: 1px solid rgba(255,255,255,0.06);
    }
    .hud-row:last-child { border-bottom: none; }
    .hud-label { color: rgba(255,255,255,0.58); }
    .hud-val--text   { color: var(--text); }
    .hud-val--red    { color: #fca5a5; }
    .hud-val--green  { color: #86efac; }
    .hud-val--purple { color: #c4b5fd; }
    #hud-plot-container {
      position: absolute;
      bottom: 6.5rem;
      left: 50%;
      transform: translateX(-50%);
      width: calc(100% - 5rem);
      max-width: 820px;
      height: 185px;
      background: rgba(7,9,26,0.55);
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 3px;
      overflow: hidden;
      opacity: 0;
      transition: opacity 0.5s;
      z-index: 10;
    }
    #sim-controls {
      position: absolute;
      bottom: 3rem;
      left: 50%;
      transform: translateX(-50%);
      z-index: 20;
      display: flex;
      align-items: center;
      pointer-events: none;
    }
    .sim-params {
      position: absolute;
      bottom: 0.75rem;
      left: 50%;
      transform: translateX(-50%);
      width: calc(100% - 4rem);
      max-width: 820px;
      z-index: 20;
      pointer-events: none;
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      letter-spacing: 0.1em;
      color: rgba(255,255,255,0.45);
      margin: 0;
      text-transform: uppercase;
      text-align: center;
    }
    .mode-pill {
      pointer-events: auto;
      background: rgba(7,9,26,0.85);
      border: 1px solid rgba(255,255,255,0.09);
      border-radius: 999px;
      padding: 0.2rem;
      display: flex;
      gap: 2px;
    }
    .btn-mode {
      background: transparent;
      color: rgba(255,255,255,0.52);
      border: none;
      padding: 0.45rem 1.4rem;
      border-radius: 999px;
      font-size: 11px;
      cursor: pointer;
      transition: background 0.2s, color 0.2s;
      letter-spacing: 0.1em;
      font-family: 'JetBrains Mono', monospace;
    }
    #sim-preview {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--bg);
      z-index: 50;
      transition: opacity 0.6s;
    }
    .sim-loading-panel {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.9rem;
      padding: 0 1.5rem;
      max-width: 480px;
      text-align: center;
    }
    .sim-load-line {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.14em;
      color: rgba(226,221,212,0.75);
      opacity: 0;
      transition: opacity 0.4s ease;
    }
    .sim-load-line:first-child {
      font-size: 13px;
      letter-spacing: 0.22em;
      color: #c4a258;
    }

    /* sim responsive layout */
    @media (max-width: 1100px) {
      #cepheid-sim {
        height: auto;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: visible;
      }
      #sim-info {
        position: relative;
        top: auto; left: auto;
        max-width: none;
        padding: 1.5rem 1.5rem 1rem;
        pointer-events: auto;
      }
      .sim-title { font-size: 24px; }
      .sim-body  { font-size: 13.5px; }
      #hud-table {
        position: relative;
        top: auto; right: auto;
        width: auto;
        margin: 0 1.5rem 1rem;
        border-radius: 0.5rem;
        padding: 1rem 1.25rem;
      }
      #sim-stage {
        position: relative;
        inset: auto;
        height: 530px;
        flex-shrink: 0;
      }
      #hud-plot-container {
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        max-width: none;
        height: 180px;
        border-radius: 0;
        border-left: none;
        border-right: none;
      }
      #sim-controls {
        position: relative;
        bottom: auto; left: auto;
        transform: none;
        padding: 1rem 1.5rem 0.5rem;
        pointer-events: auto;
        align-self: center;
      }
      .sim-params {
        position: relative;
        bottom: auto; left: auto;
        transform: none;
        width: auto;
        max-width: none;
        padding: 0 1.5rem 1.5rem;
        font-size: 10px;
      }
      #rv-legend  { display: none; }
    }

    /* bookshelf */
    #bookshelf {
      background: var(--panel);
      border-top: 1px solid var(--panel-border);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      padding: 100px 52px;
    }

    .bookshelf-intro {
      max-width: 600px;
      margin-bottom: 3.5rem;
    }

    .bookshelf-intro p {
      font-size: 16px;
      color: var(--text-dim);
      line-height: 1.75;
    }

    .bookshelf-intro a {
      color: var(--blue);
      text-decoration: none;
      border-bottom: 1px solid var(--blue);
      transition: opacity 0.18s;
      opacity: 0.65;
    }
    .bookshelf-intro a:hover { opacity: 1; }

    /* shelf row */
    .book-shelf {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 5px;
      padding-bottom: 0;
      overflow-x: auto;
      overflow-y: visible;
      scrollbar-width: none;
      -ms-overflow-style: none;
      padding-top: 14px;
      margin-bottom: 0;
    }
    .book-shelf::-webkit-scrollbar { display: none; }

    /* shelf surface line */
    .book-shelf-surface {
      height: 2px;
      background: linear-gradient(to right, var(--panel-border), rgba(196,162,88,0.35), var(--panel-border));
      margin-top: 0;
      margin-bottom: 20px;
      border-radius: 1px;
    }
    
    /* individual book spine — base height; JS overrides per content length */
    .book-spine {
      position: relative;
      flex-shrink: 0;
      width: 46px;
      height: 220px;
      background: rgba(196,162,88,0.05);
      border: 2px solid var(--panel-border);
      border-bottom: 2px solid rgba(196,162,88,0.22);
      cursor: pointer;
      overflow: hidden;
      transition: width 0.35s cubic-bezier(0.22,1,0.36,1),
                  transform 0.25s cubic-bezier(0.22,1,0.36,1);
    }
    .book-spine::after {
      content: '';
      position: absolute;
      inset: 0;
      border: 1px solid rgba(196,162,88,0.42);
      opacity: 0;
      transition: opacity 0.25s ease;
      pointer-events: none;
    }

    /* hover and .active share identical expanded state */
    .book-spine:hover,
    .book-spine.active {
      width: 172px;
      transform: translateY(-8px);
      z-index: 2;
    }
    .book-spine:hover::after,
    .book-spine.active::after {
      opacity: 1;
    }

    /* subtle tint variation per book */
    .book-spine:nth-child(odd)  { background: rgba(196,162,88,0.04); }
    .book-spine:nth-child(even) { background: rgba(120,165,210,0.04); }
    .book-spine:nth-child(3n)   { background: rgba(94,207,191,0.03); }

    /* rotated spine title — visible when collapsed */
    .spine-title {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: none;
      transition: opacity 0.18s ease;
    }

    .spine-title span {
      display: block;
      white-space: nowrap;
      font-family: 'EB Garamond', serif;
      font-size: 12px;
      letter-spacing: 0.05em;
      color: rgba(226,221,212,0.60);
      writing-mode: vertical-rl;
      transform: rotate(180deg);
      text-align: center;
      max-height: 180px;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* hide title on hover or active tap */
    .book-spine:hover .spine-title,
    .book-spine.active .spine-title {
      opacity: 0;
    }

    /* expanded info panel — fades in on hover or tap */
    .spine-panel {
      position: absolute;
      inset: 0;
      padding: 16px 14px 14px;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      gap: 5px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.18s 0.12s ease;
    }

    .book-spine:hover .spine-panel,
    .book-spine.active .spine-panel {
      opacity: 1;
    }

    .spine-book-title {
      font-family: 'EB Garamond', serif;
      font-size: 13px;
      line-height: 1.3;
      color: var(--text);
      font-weight: 500;
    }

    .spine-author {
      font-family: 'Spectral', serif;
      font-style: italic;
      font-size: 12px;
      color: var(--gold);
      line-height: 1.3;
    }

    .spine-impact {
      font-family: 'Spectral', serif;
      font-size: 12px;
      color: rgba(226,221,212,0.65);
      line-height: 1.5;
      margin-top: 5px;
    }

    /* mobile: scrollable shelf stays, slightly smaller */
    @media (max-width: 740px) {
      #bookshelf { padding: 72px 24px; }
      .book-spine { width: 40px; }
      .book-spine:hover,
      .book-spine.active { width: 150px; }
    }

    /* animations */
    /* profile image frame */
    .profile-frame {
      width: 100%;
      aspect-ratio: 613 / 661; /* mirrors image ratio — grid column height stable at parse time */
      margin-bottom: 2rem;
      padding: 6px;
      border: 1px solid var(--gold-dim);
      background: rgba(196, 162, 88, 0.05);
      line-height: 0;
    }

    .profile-frame img {
      width: 100%;
      height: auto;
      aspect-ratio: 613 / 661; /* reserves space before image loads — eliminates CLS */
      display: block;
      opacity: 0.95;
      transition: opacity 0.4s ease;
    }

    /* LQIP state: dimmed while tiny placeholder is visible; blur comes
       naturally from the 80px source scaled up — no CSS filter needed */
    .profile-frame img.profile-img-lqip {
      opacity: 0.6;
    }

    /* research card deep-link from modal */
    .modal-card-link {
      display: inline-block;
      margin-top: 10px;
      margin-left: 12px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      letter-spacing: 0.04em;
      color: var(--gold);
      text-decoration: none;
      opacity: 0.82;
      transition: opacity 0.15s;
    }
    .modal-card-link:hover { opacity: 1; }

    
/* card call-to-action base layout */
.card-cta {
  display: block;
  margin-top: 24px;
  padding: 16px 20px;
  border: 1px solid rgba(120, 165, 210, 0.22);
  background: rgba(120, 165, 210, 0.04);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}
/* card call-to-action block hover — replaces inline onmouseover/onmouseout */
    .card-cta:hover {
      border-color: rgba(120, 165, 210, 0.45) !important;
      background: rgba(120, 165, 210, 0.09) !important;
    }


    @media (max-width: 740px) {
      .section { padding: 72px 24px; }
      .about-grid { grid-template-columns: 1fr; gap: 44px; }
      .highlights-row { grid-template-columns: 1fr; gap: 6px; }
      footer { flex-direction: column; gap: 20px; align-items: flex-start; padding: 36px 24px; }
      .footer-cssda img { width: 32px; height: 32px; }
      #modal-img-wrap { aspect-ratio: 4 / 3; margin-bottom: 20px; }
    }

    /* ── reading trail ─────────────────────────────────────────────────────── */
    .trail-word {
      border-bottom: 1px dotted rgba(196,162,88,0.35);
      cursor: pointer;
      transition: color 0.15s, border-bottom-color 0.15s;
    }
    .trail-active .trail-word {
      border-bottom-style: solid;
      border-bottom-color: rgba(196,162,88,0.6);
    }
    .trail-active .trail-word:hover {
      border-bottom-color: var(--gold);
      color: rgba(226,221,212,0.9);
    }
    .trail-active .trail-word.found {
      color: var(--gold);
      border-bottom-color: var(--gold);
    }

    /* toggle — left side, clear of back-to-top */
    #trail-toggle {
      position: fixed;
      bottom: 32px;
      left: 32px;
      z-index: 300;
      width: 40px;
      height: 40px;
      background: var(--panel);
      border: 1px solid var(--panel-border);
      cursor: pointer;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease, border-color 0.18s, width 0.25s ease, padding 0.25s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      overflow: hidden;
      white-space: nowrap;
    }
    #trail-toggle img {
      width: 26px;
      height: 26px;
      display: block;
      flex-shrink: 0;
      opacity: 0.85;
      transition: opacity 0.18s;
    }
    /* label shown once on first visit, before any word is found */
    #trail-toggle .trail-toggle-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--gold);
      opacity: 0;
      transition: opacity 0.25s ease 0.1s;
      pointer-events: none;
    }
    #trail-toggle.trail-ready {
      opacity: 1;
      pointer-events: auto;
    }
    #trail-toggle.trail-on {
      border-color: var(--gold);
    }
    #trail-toggle.trail-on img { opacity: 1; }
    #trail-toggle:hover {
      border-color: var(--gold);
    }
    #trail-toggle:hover img { opacity: 1; }

    /* floating card */
    #trail-card {
      position: fixed;
      bottom: 80px;
      left: 32px;
      z-index: 300;
      width: 214px;
      background: rgba(7,9,26,0.97);
      border: 1px solid var(--panel-border);
      padding: 18px 20px 16px;
      opacity: 0;
      pointer-events: none;
      transform: translateY(6px);
      transition: opacity 0.2s, transform 0.2s;
    }
    #trail-card.trail-card-visible {
      opacity: 1;
      pointer-events: all;
      transform: translateY(0);
    }
    .trail-card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 14px;
    }
    .trail-card-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      letter-spacing: 0.2em;
      color: var(--gold);
      text-transform: uppercase;
    }
    .trail-card-count {
      font-family: 'JetBrains Mono', monospace;
      font-size: 11px;
      color: var(--text-dim);
    }
    .trail-card-count em { font-style: normal; color: var(--gold); }
    .trail-dots {
      display: flex;
      flex-wrap: wrap;
      gap: 7px;
      margin-bottom: 14px;
    }
    .trail-dot {
      width: 7px;
      height: 7px;
      border: 1px solid rgba(196,162,88,0.28);
      border-radius: 50%;
      transition: background 0.2s, border-color 0.2s;
    }
    .trail-dot.trail-dot-lit {
      background: var(--gold);
      border-color: var(--gold);
    }
    .trail-words-list {
      display: flex;
      flex-direction: column;
      gap: 5px;
      min-height: 20px;
    }
    .trail-found-word {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10.5px;
      letter-spacing: 0.05em;
      color: var(--gold);
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 0.25s, transform 0.25s;
      cursor: pointer;
    }
    .trail-found-word:hover {
      text-decoration: underline;
      text-underline-offset: 3px;
    }
    .trail-word.trail-scroll-highlight {
      color: var(--gold);
      border-bottom: 1px solid var(--gold);
      transition: color 0.3s, border-color 0.3s;
    }
    #trail-connect {
      margin-top: 10px;
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 0.5s 0.6s, transform 0.5s 0.6s;
    }
    #trail-connect.trail-connect-show {
      opacity: 1;
      transform: translateY(0);
    }
    #trail-connect-msg {
      font-family: 'Spectral', serif;
      font-size: 12px;
      font-style: italic;
      color: var(--text-dim);
      margin: 0 0 7px;
      line-height: 1.5;
    }
    .trail-connect-link {
      font-family: 'JetBrains Mono', monospace;
      font-size: 10px;
      color: var(--gold);
      text-decoration: none;
      letter-spacing: 0.03em;
    }
    .trail-connect-link:hover {
      text-decoration: underline;
      text-underline-offset: 3px;
    }
    .trail-found-word.trail-word-show {
      opacity: 1;
      transform: translateY(0);
    }
    #trail-dismiss {
      position: absolute;
      top: 10px;
      right: 12px;
      background: none;
      border: none;
      color: var(--text-dim);
      font-size: 14px;
      cursor: pointer;
      opacity: 0.45;
      transition: opacity 0.15s;
      font-family: 'EB Garamond', 'EB Garamond Fallback', serif;
      line-height: 1;
    }
    #trail-dismiss:hover { opacity: 1; }
    #trail-complete {
      font-family: 'Spectral', serif;
      font-size: 13px;
      font-style: italic;
      color: var(--text-dim);
      margin-top: 12px;
      border-top: 1px solid var(--panel-border);
      padding-top: 12px;
      opacity: 0;
      transition: opacity 0.5s 0.3s;
    }
    #trail-complete.trail-complete-show { opacity: 1; }
    @keyframes trail-flash {
      0%   { box-shadow: 0 0 0 0 rgba(196,162,88,0); border-color: var(--panel-border); }
      35%  { box-shadow: 0 0 20px 6px rgba(196,162,88,0.22); border-color: rgba(196,162,88,0.7); }
      100% { box-shadow: 0 0 0 0 rgba(196,162,88,0); border-color: var(--panel-border); }
    }
    #trail-card.trail-flash { animation: trail-flash 1.4s ease forwards; }

    /* in-card hint text */
    #trail-hint-text {
      font-family: 'Spectral', serif;
      font-size: 11.5px;
      font-style: italic;
      color: var(--text-dim);
      opacity: 0.7;
      margin: 0 0 10px;
      line-height: 1.5;
      transition: opacity 0.4s, max-height 0.4s;
      max-height: 40px;
      overflow: hidden;
    }
    #trail-hint-text.trail-hint-gone {
      opacity: 0;
      max-height: 0;
      margin: 0;
    }

    /* floating arrow callout */
    /* first-word hint — pulses the underline of the first unclicked word when trail opens */
    @keyframes first-word-hint {
      0%   { border-bottom-color: rgba(196,162,88,0.6); }
      30%  { border-bottom-color: rgba(196,162,88,1);   }
      60%  { border-bottom-color: rgba(196,162,88,0.6); }
      80%  { border-bottom-color: rgba(196,162,88,0.9); }
      100% { border-bottom-color: rgba(196,162,88,0.6); }
    }
    .trail-active .trail-word.trail-first {
      animation: first-word-hint 1.8s ease 0.3s 2;
    }

/* epilepsy warning modal */
.epilepsy-body {
  font-size: 13px;
  color: rgba(226,221,212,0.85);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}
#epilepsy-modal {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(7,9,26,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}
#epilepsy-modal.visible {
  opacity: 1;
  pointer-events: all;
}
#epilepsy-modal > div { pointer-events: none; }
#epilepsy-modal.visible > div { pointer-events: auto; }
.epilepsy-btn {
  flex: 1;
  padding: 0.6rem;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.epilepsy-btn--cancel {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
}
.epilepsy-btn--cancel:hover {
  border-color: rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.75);
}
.epilepsy-btn--confirm {
  background: rgba(196,162,88,0.12);
  border: 1px solid rgba(196,162,88,0.4);
  color: #c4a258;
}
.epilepsy-btn--confirm:hover {
  background: rgba(196,162,88,0.22);
  border-color: rgba(196,162,88,0.65);
}
