/*
Theme Name: Observatory
Theme URI: https://github.com/observatory-theme
Description: A cerebral, brutalist personal site. Essays as stars. Books as history. No identity, just ideas.
Version: 2.7.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: observatory
*/

/* ============================================================
   RESET & FULL-SCREEN FOUNDATION
   Forces full viewport on WordPress.com Business plan.
   These !important declarations override WP.com platform styles.
   ============================================================ */

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

html {
  margin-top: 0 !important;
  padding: 0 !important;
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100%;
  background: #050508;
  color: rgba(255,255,255,0.9);
  font-family: 'JetBrains Mono', monospace;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Kill WordPress.com admin bar for visitors */
#wpadminbar {
  display: none !important;
}

/* Kill any WordPress.com wrapper constraints */
.site,
.site-content,
.site-main,
.entry-content,
.post-content,
.page-content,
.content-area,
#content,
#main,
#page,
#primary,
.wp-site-blocks {
  max-width: none !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ============================================================
   VARIABLES
   ============================================================ */

:root {
  --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --bg: #050508;
  --grid-faint: rgba(255,255,255,0.025);
  --grid-accent: rgba(255,255,255,0.05);
  --text-dim: rgba(255,255,255,0.3);
  --text-mid: rgba(255,255,255,0.6);
  --text-bright: rgba(255,255,255,0.9);
  --accent: rgba(200,180,140,0.8);
  --accent-solid: #c8b48c;
  --strip-height: 54px;
}

/* ============================================================
   OBSERVATORY PAGE (front-page.php)
   ============================================================ */

body.observatory-home {
  overflow: hidden !important;
  height: 100vh !important;
  width: 100vw !important;
  cursor: none;
}

/* Grid overlay */
.obs-grid {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-faint) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-faint) 1px, transparent 1px),
    linear-gradient(var(--grid-accent) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-accent) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}

/* Nebula canvas (behind stars, above grid) */
#obs-nebula-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

/* Star field canvas */
#obs-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}

/* Cursor light mask */
.obs-light {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* Custom cursor */
.obs-cursor {
  position: fixed;
  width: 8px; height: 8px;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s, border-color 0.3s;
  display: none;
}
body.observatory-home .obs-cursor { display: block; }
.obs-cursor.hovering {
  width: 20px; height: 20px;
  border-color: var(--accent);
}

/* Site title + coordinate block */
.obs-title-block {
  position: fixed;
  top: 28px; left: 24px;
  z-index: 10;
  pointer-events: none;
}
.obs-site-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  font-style: italic;
  color: rgba(255,255,255,0.45);
  letter-spacing: 1px;
  margin-bottom: 10px;
}

/* Coordinate readouts */
.obs-coords {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  pointer-events: none;
}
.obs-coords-tl {
  /* Now positioned within .obs-title-block, no fixed needed */
}
.obs-coords-br {
  position: fixed;
  bottom: 60px; right: 20px;
  text-align: right;
  z-index: 10;
}

/* Hover card */
.obs-hover-card {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  max-width: 360px;
}
.obs-hover-card.visible { opacity: 1; }
.obs-hover-card-inner {
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  background: rgba(5,5,8,0.9);
  backdrop-filter: blur(8px);
}
.obs-hover-card-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-bright);
  margin-bottom: 6px;
  line-height: 1.3;
}
.obs-hover-card-fragment {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mid);
  line-height: 1.5;
  margin-bottom: 8px;
  font-style: italic;
}
.obs-hover-card-meta {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Intro overlay */
.obs-intro {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 500;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1.5s ease;
  cursor: default;
}
.obs-intro.fading { opacity: 0; pointer-events: none; }
.obs-intro-text {
  font-family: var(--mono);
  font-size: 18px;
  letter-spacing: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: obsPulse 2s ease-in-out infinite;
}
@media (max-width: 768px) {
  .obs-intro-text {
    font-size: 16px;
    letter-spacing: 8px;
  }
}
@keyframes obsPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* Writing index side panel */
.obs-writing-panel {
  position: fixed;
  top: 0; right: -480px;
  width: 480px; height: 100%;
  z-index: 200;
  background: rgba(5,5,8,0.95);
  backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255,255,255,0.06);
  transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  padding: 60px 40px;
  cursor: default;
}
.obs-writing-panel.open { right: 0; }
.obs-writing-panel::-webkit-scrollbar { width: 2px; }
.obs-writing-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.obs-panel-header {
  font-size: 9px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.obs-panel-close {
  font-size: 18px;
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--mono);
  transition: color 0.2s;
}
.obs-panel-close:hover { color: var(--text-bright); }

.obs-index-item {
  display: block;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: padding-left 0.2s;
  text-decoration: none;
}
.obs-index-item:hover { padding-left: 8px; }
.obs-index-item-title {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--text-mid);
  margin-bottom: 4px;
  transition: color 0.2s;
}
.obs-index-item:hover .obs-index-item-title { color: var(--text-bright); }
.obs-index-item-meta {
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.2);
  text-transform: uppercase;
}

/* Search overlay — transparent so stars remain crisp and clickable */
.obs-search-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: auto;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12vh;
  padding-bottom: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  background: linear-gradient(to bottom, rgba(5,5,8,0.85) 0%, rgba(5,5,8,0.6) 70%, transparent 100%);
}
.obs-search-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.obs-search-close {
  position: fixed;
  top: 24px; right: 24px;
  font-family: var(--mono);
  font-size: 28px;
  color: var(--text-dim);
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  line-height: 1;
}
.obs-search-close:hover {
  color: var(--text-bright);
  border-color: rgba(255,255,255,0.2);
}
.obs-search-hint {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 16px;
}
.obs-search-input {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 300;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  color: var(--text-bright);
  width: 400px;
  max-width: 90vw;
  padding: 12px 0;
  outline: none;
  letter-spacing: 2px;
  text-align: center;
  caret-color: var(--accent-solid);
}
.obs-search-input::placeholder {
  color: var(--text-dim);
  font-weight: 300;
}

/* Sonar ring */
.obs-sonar-ring {
  position: fixed;
  border-radius: 50%;
  border: 1px solid rgba(200,180,140,0.3);
  pointer-events: none;
  z-index: 5;
  transform: translate(-50%, -50%);
  animation: obsSonar 2s ease-out forwards;
}
@keyframes obsSonar {
  0% { width: 0; height: 0; opacity: 0.6; }
  100% { width: 150vmax; height: 150vmax; opacity: 0; }
}

/* Time slider */
.obs-time-slider-wrap {
  position: fixed;
  bottom: 68px; left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.obs-time-slider-wrap.visible {
  opacity: 1;
  pointer-events: auto;
}
.obs-time-slider-wrap label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.obs-time-slider {
  -webkit-appearance: none;
  width: 300px;
  height: 1px;
  background: rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
}
.obs-time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  background: var(--accent-solid);
  border-radius: 50%;
  cursor: pointer;
}

/* ============================================================
   CONTROL STRIP (appears on all pages)
   ============================================================ */

.obs-control-strip {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--strip-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(5,5,8,0.7);
  backdrop-filter: blur(12px);
  font-family: var(--mono);
  cursor: default;
}
.obs-strip-left,
.obs-strip-right {
  display: flex;
  align-items: center;
  gap: 24px;
}
.obs-strip-btn {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 0;
  position: relative;
  transition: color 0.3s;
  text-decoration: none;
  display: inline-block;
}
.obs-strip-btn:hover { color: var(--text-bright); }
.obs-strip-btn.active { color: var(--accent); }
.obs-strip-btn.active::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
}
.obs-strip-indicator {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ============================================================
   READING VIEW (single.php — essays)
   ============================================================ */

body.observatory-reading {
  overflow-y: auto;
  background: var(--bg);
}

.reading-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px 120px;
  min-height: 100vh;
}

.reading-back {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 48px;
  transition: color 0.2s;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 8px 16px;
}
.reading-back:hover {
  color: var(--text-bright);
  border-color: rgba(255,255,255,0.2);
}

.reading-topic {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.reading-title {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--text-bright);
  margin-bottom: 12px;
}

.reading-date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 48px;
}

.reading-body {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-mid);
}
.reading-body p { margin-bottom: 24px; }
.reading-body h2, .reading-body h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 48px 0 16px;
  font-weight: 400;
}
.reading-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reading-body a:hover { color: var(--text-bright); }
.reading-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 20px;
  margin: 32px 0;
  font-style: italic;
  color: var(--text-dim);
}
.reading-body img {
  max-width: 100%;
  height: auto;
  margin: 32px 0;
}
.reading-body ul, .reading-body ol {
  margin: 16px 0;
  padding-left: 24px;
}
.reading-body li {
  margin-bottom: 8px;
}

/* Related essays */
.reading-related {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.reading-related-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.reading-related-item {
  display: block;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  text-decoration: none;
  transition: padding-left 0.2s;
}
.reading-related-item:hover { padding-left: 8px; }
.reading-related-item-title {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-mid);
  transition: color 0.2s;
}
.reading-related-item:hover .reading-related-item-title { color: var(--text-bright); }
.reading-related-item-meta {
  font-family: var(--mono);
  font-size: 9px;
  color: rgba(255,255,255,0.2);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ============================================================
   BOOK PAGE (page.php)
   ============================================================ */

body.observatory-page {
  overflow-y: auto;
  background: var(--bg);
}

.page-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px 120px;
  min-height: 100vh;
}

/* Wide and full-width blocks break out of the narrow container */
.page-body .alignwide {
  max-width: 1200px;
  margin-left: calc(50% - 600px);
  margin-right: calc(50% - 600px);
  width: auto;
}
.page-body .alignfull {
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  width: 100vw;
}

/* Full-width page template — no narrow container at all */
.page-container-full {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 40px 120px;
  min-height: 100vh;
}
.page-container-full .page-body {
  max-width: none;
}

@media (max-width: 1240px) {
  .page-body .alignwide {
    max-width: calc(100vw - 40px);
    margin-left: -20px;
    margin-right: -20px;
  }
  .page-container-full {
    padding: 40px 20px 100px;
  }
}

.page-cover {
  max-width: 240px;
  margin-bottom: 40px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.page-cover img {
  width: 100%;
  height: auto;
  display: block;
}

.page-title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-bright);
  margin-bottom: 16px;
}

.page-body {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-mid);
}
.page-body p { margin-bottom: 24px; }
.page-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.page-body a:hover { color: var(--text-bright); }
.page-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 20px;
  margin: 32px 0;
  font-style: italic;
  color: var(--text-dim);
}
.page-body img {
  max-width: 100%;
  height: auto;
  margin: 32px 0;
}

/* ============================================================
   BOOKS GALLERY (template-books-gallery.php)
   ============================================================ */

body.observatory-books-gallery {
  overflow-y: auto;
  background: var(--bg);
}

.books-gallery-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 40px 120px;
  min-height: 100vh;
}

.books-gallery-header {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 60px;
}

.books-year-divider {
  font-family: var(--mono);
  font-size: 48px;
  font-weight: 300;
  color: rgba(255,255,255,0.08);
  margin: 60px 0 24px;
  letter-spacing: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding-bottom: 16px;
}
.books-year-divider:first-of-type {
  margin-top: 0;
}

.books-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 24px;
  margin-bottom: 20px;
}

.books-gallery-item {
  display: block;
  text-decoration: none;
  transition: transform 0.3s ease, opacity 0.3s;
  opacity: 0.75;
}
.books-gallery-item:hover {
  transform: translateY(-4px);
  opacity: 1;
}
.books-gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: box-shadow 0.3s;
}
.books-gallery-item:hover img {
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.books-gallery-item-title {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.4;
  transition: color 0.3s;
}
.books-gallery-item:hover .books-gallery-item-title {
  color: var(--text-mid);
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  /* Observatory: show cursor as normal on touch */
  body.observatory-home {
    cursor: default;
  }
  .obs-cursor { display: none !important; }
  .obs-light { display: none !important; }
  .obs-title-block { display: none; }
  .obs-coords-br { display: none; }

  /* Writing panel full width */
  .obs-writing-panel {
    width: 100%;
    right: -100%;
    padding: 40px 20px;
  }

  /* Control strip */
  .obs-strip-right { display: none; }
  .obs-strip-left { gap: 16px; }
  .obs-strip-btn { font-size: 11px; letter-spacing: 2px; }

  /* Hide search on mobile — not usable with touch */
  #obs-btn-search { display: none !important; }
  .obs-search-overlay,
  .obs-search-overlay.visible,
  div.obs-search-overlay,
  div#obs-search-overlay { display: none !important; }

  /* Reading */
  .reading-container { padding: 40px 20px 100px; }
  .reading-title { font-size: 28px; }
  .reading-body { font-size: 16px; }
  .reading-back { margin-bottom: 32px; }

  /* Page */
  .page-container { padding: 40px 20px 100px; }
  .page-title { font-size: 26px; }
  .page-body { font-size: 16px; }

  /* Books gallery */
  .books-gallery-container { padding: 40px 20px 100px; }
  .books-year-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
  }
  .books-year-divider { font-size: 32px; }

  /* Time slider */
  .obs-time-slider { width: 200px; }
}

@media (max-width: 480px) {
  .books-year-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* ============================================================
   SCROLLBAR STYLING (all pages)
   ============================================================ */

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   WORDPRESS BLOCK EDITOR CONTENT OVERRIDES
   Ensures block editor content looks good in our dark theme
   ============================================================ */

.wp-block-image { margin: 32px 0; }
.wp-block-image img { max-width: 100%; height: auto; }

/* Linked images: subtle zoom on hover so users know it's clickable */
a img,
a .wp-block-image img,
.wp-block-image a img,
.page-body a img,
.reading-body a img,
.books-gallery-item img {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
a:hover img,
a:hover .wp-block-image img,
.wp-block-image a:hover img,
.page-body a:hover img,
.reading-body a:hover img {
  transform: scale(1.03);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.wp-block-quote {
  border-left: 2px solid var(--accent) !important;
  padding-left: 20px !important;
  margin: 32px 0 !important;
  font-style: italic;
  color: var(--text-dim) !important;
}
.wp-block-separator {
  border-color: rgba(255,255,255,0.06) !important;
  margin: 48px 0 !important;
}
.has-text-align-center { text-align: center; }
figure { margin: 0; }
figcaption {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}
