/**
 * TalkingScientist Theme
 * Main Stylesheet
 * Contact centers × Science × Controlled chaos.
 */

/* ==========================================================================
   Design Tokens - CSS Custom Properties
   ========================================================================== */

:root {
  /* Colors - Dark Theme */
  --bg: #0B0C0E;             /* Lab Night */
  --surface: #121316;        /* Dark Steel */
  --muted-surface: #17181C;
  --hairline: #ff0000;       /* Graphite */
  --text-1: #E5E7EB;         /* Mist */
  --text-2: #9CA3AF;         /* Zinc */
  --accent: #ff0000;         /* Signal Red */
  --accent-visit: #ff0000;
  --accent-2: #ff0000;       /* Ion Cyan */
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #DC2626;

  /* Typography */
  --font-sans: "Space Grotesk";
  --font-head: "Space Grotesk", var(--font-sans);
  --font-mono: monospace;

  /* Spacing & Radius */
  --sp-1: 8px;
  --sp-2: 12px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --sp-6: 48px;
  --sp-7: 64px;
  --radius-1: 2px;
  --radius-2: 4px;

  /* Effects */
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 150ms ease-out;
  --transition-base: 200ms ease-out;
}

/* Light Theme Override - Removed, always default to dark theme
   Users can manually toggle to light theme using the Dark/Light link */

/* User preference for dark theme */
body.theme-dark {
  --bg: #0B0C0E;
  --surface: #121316;
  --muted-surface: #17181C;
  --text-1: #E5E7EB;
  --text-2: #9CA3AF;
  --hairline: #ff0000;
  --accent: #ff0000;
  --accent-visit: #ff0000;
  --accent-2: #ff0000;
}

body.theme-light {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --muted-surface: #F6F7F8;
  --text-1: #0B0C0E;
  --text-2: #4B5563;
  --hairline: #ff0000;
  --accent: #ff0000;
  --accent-visit: #ff0000;
  --accent-2: #ff0000;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

html {
  box-sizing: border-box;
  font-size: 16px;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: small;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  margin: 0 0 var(--sp-3);
  line-height: 1.2;
  font-weight: 600;
}

h1 {
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.15;
}

h2,
.wp-block-heading {
  font-size: larger;
  line-height: 1.2;
}

h3 {
  font-size: 18px;
  line-height: 1.25;
}

p {
  margin: 0 0 var(--sp-3);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: all var(--transition-fast);
}

a:visited {
  color: var(--accent-visit);
}

a:hover {
  text-decoration-thickness: 2px;
  filter: brightness(1.04);
}

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

/* Lists */
ul, ol {
  margin: 0 0 var(--sp-3);
  padding-left: var(--sp-4);
}

li {
  margin-bottom: var(--sp-1);
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Code */
code, kbd, samp, pre {
  font-family: var(--font-mono);
}

code {
  font-size: 0.9em;
  color: var(--accent-2);
  padding: 2px 4px;
  border-radius: var(--radius-1);
}

pre {
  background: var(--muted-surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-2);
  padding: var(--sp-3);
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  color: var(--text-1);
  padding: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--sp-4);
}

th, td {
  padding: var(--sp-2);
  border: 1px solid var(--hairline);
  text-align: left;
}

th {
  background: var(--muted-surface);
  font-weight: 600;
}

/* ==========================================================================
   Layout & Grid
   ========================================================================== */

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  padding: var(--sp-3) var(--sp-5);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-1);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
}

.site-title {
  margin: 0;
  font-size: 24px;
}

.site-title a {
  text-decoration: none;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.site-title a:hover {
  color: var(--accent);
}

.site-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.site-tagline {
  font-size: 14px;
  color: var(--text-2);
  font-family: var(--font-mono);
  margin: 0;
}

.main-wrapper {
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex: 1;
  position: relative;
}

.sidebar-left {
  position: fixed;
  left: 0;
  top: 73px; /* Adjust based on header height */
  width: 280px;
  height: calc(100vh - 73px);
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg);
  border-right: 1px solid var(--hairline);
}

.site-content {
  flex: 1;
  margin-left: 280px;
  margin-right: 300px;
  padding-left: 0px;
  padding-right: 0px;
  padding-top: 0px;
  padding-bottom: 0px;
  min-width: 0;
}

.sidebar-right {
  position: fixed;
  right: 0;
  top: 73px; /* Adjust based on header height */
  width: 300px;
  height: calc(100vh - 73px);
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg);
  border-left: 1px solid var(--hairline);
}

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  padding: var(--sp-4) var(--sp-5);
  margin-top: var(--sp-6);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  font-size: 14px;
  color: var(--text-2);
}

/* Responsive Layout */
@media (max-width: 1024px) {
  .sidebar-left {
    width: 220px;
  }

  .site-content {
    margin-left: 220px;
    margin-right: 0;
    padding-left: 0px;
    padding-right: 0px;
    padding-top: 0px;
    padding-bottom: 0px;
  }

  .sidebar-right {
    position: relative;
    right: auto;
    top: auto;
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--hairline);
    margin-left: 220px;
  }
}

@media (max-width: 768px) {
  .main-wrapper {
    flex-direction: column;
  }

  .sidebar-left {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--hairline);
  }

  .site-content {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0px;
    padding-right: 0px;
    padding-top: 0px;
    padding-bottom: 0px;
  }

  .sidebar-right {
    margin-left: 0;
  }

  .site-header {
    padding: var(--sp-3);
  }

  .site-footer {
    padding: var(--sp-3);
  }
}

/* ==========================================================================
   Components
   ========================================================================== */

/* Card */
.card {
  background: var(--surface);
  border: 1px solid #ff0000;
  border-radius: var(--radius-1);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--sp-4);
}

.card:hover {
  transition: transform var(--transition-base);
}

.card.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

/* Label */
.label,
#block-2 .wp-block-heading,
#block-3 .wp-block-heading,
#block-4 .wp-block-heading,
.wp-block-group .wp-block-heading {
  color: var(--text-2);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--hairline);
  display: block;
}

/* WordPress Block Groups - Reset and Navigation-like styling */
#block-2,
#block-3,
#block-4,
.wp-block-group {
  margin-bottom: var(--sp-4);
}

#block-2 ul,
#block-3 ul,
#block-4 ul,
.wp-block-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#block-2 li,
#block-3 li,
#block-4 li,
.wp-block-group li {
  margin: 0;
}

#block-2 a,
#block-3 a,
#block-4 a,
.wp-block-group a {
  display: block;
  padding: 6px 0;
  text-decoration: none;
  color: var(--text-1);
  border-left: 2px solid transparent;
  padding-left: 10px;
  transition: all var(--transition-fast);
}

#block-2 a:hover,
#block-3 a:hover,
#block-4 a:hover,
.wp-block-group a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Navigation */
.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-menu li {
  margin: 0;
}

.nav-menu a {
  display: block;
  padding: 6px 0;
  text-decoration: none;
  color: var(--text-1);
  border-left: 2px solid transparent;
  padding-left: 10px;
  transition: all var(--transition-fast);
}

.nav-menu a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-menu a.current,
.nav-menu a[aria-current="page"] {
  font-weight: 600;
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Post Meta Rails */
.post-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 14px;
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  padding: var(--sp-2) 0;
  margin: var(--sp-3) 0 var(--sp-4);
}

.post-meta-author {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.post-meta-author::before {
  content: "::";
  color: var(--accent);
}

.post-meta-time {
  color: var(--text-2);
}

@media (max-width: 640px) {
  .post-meta {
    grid-template-columns: 1fr;
    gap: var(--sp-1);
  }
}

/* Post Content */
.post-content {
  max-width: 75ch;
}

.post-content > * + * {
  margin-top: var(--sp-3);
}

.post-content h2 {
  margin-top: var(--sp-5);
}

.post-content h3 {
  margin-top: var(--sp-4);
}

/* Post Footer */
.post-footer {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--hairline);
}

/* Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--sp-3);
}

.tag {
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.tag:hover {
  background: var(--accent-2);
  color: var(--bg);
}

/* Lab Note Variant */
.lab-note .post-meta {
  border-top-color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

/* Callouts */
.callout {
  background: var(--muted-surface);
  border: 1px solid var(--hairline);
  padding: var(--sp-3);
  border-radius: var(--radius-1);
  margin: var(--sp-4) 0;
}

.callout-title {
  font-weight: 600;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.callout.alert {
  border-color: var(--accent);
  border-left-width: 4px;
}

.callout.alert .callout-title {
  color: var(--accent);
}

.callout.hypothesis {
  border-color: var(--accent-2);
  border-left-width: 4px;
}

.callout.hypothesis .callout-title {
  color: var(--accent-2);
}

.callout.success {
  border-color: var(--success);
  border-left-width: 4px;
}

.callout.success .callout-title {
  color: var(--success);
}

/* Search Form */
.search-form {
  display: flex;
  gap: var(--sp-1);
}

.search-form input[type="search"] {
  flex: 1;
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
select,
textarea {
  color: var(--text-1);
  background: var(--muted-surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-2);
  padding: 10px 12px;
  font: inherit;
  width: 100%;
  transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-color: var(--accent-2);
}

/* Buttons */
button,
.button,
input[type="submit"],
input[type="button"] {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-2);
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all var(--transition-fast);
}

button:hover,
.button:hover,
input[type="submit"]:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

button:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.secondary,
.button.secondary {
  background: var(--accent-2);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 14px;
}

.pagination a {
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-1);
  transition: all var(--transition-fast);
}

.pagination a:hover {
  border-color: var(--accent);
  background: var(--muted-surface);
}

.pagination .prev::before {
  content: "← ";
}

.pagination .next::after {
  content: " →";
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}

.gallery-item {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-1);
  overflow: hidden;
  transition: all var(--transition-base);
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* Archive List */
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-list li {
  margin-bottom: var(--sp-2);
}

.archive-year {
  font-weight: 600;
  color: var(--accent);
  margin-top: var(--sp-3);
  margin-bottom: var(--sp-2);
}

/* Comments */
.comments-area {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 2px solid var(--hairline);
}

.comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.comment {
  background: var(--muted-surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-1);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.comment-author {
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.comment-meta {
  font-size: 14px;
  color: var(--text-2);
  font-family: var(--font-mono);
  margin-bottom: var(--sp-2);
}

.comment-content p:last-child {
  margin-bottom: 0;
}

.children {
  list-style: none;
  padding-left: var(--sp-4);
  margin-top: var(--sp-3);
}

/* Command Palette */
.command-palette {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  background: var(--surface);
  border: 2px solid var(--accent-2);
  border-radius: var(--radius-2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: none;
}

.command-palette.active {
  display: block;
}

.command-palette-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: var(--sp-3);
  font-size: 18px;
  background: transparent;
  color: var(--text-1);
}

.command-palette-results {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--sp-2);
}

.command-palette-item {
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  border-radius: var(--radius-1);
  transition: background var(--transition-fast);
}

.command-palette-item:hover,
.command-palette-item.selected {
  background: var(--muted-surface);
}

.command-palette-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  display: none;
}

.command-palette-overlay.active {
  display: block;
}

/* Theme Toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--text-1);
  padding: 8px 12px;
  font-size: 14px;
}

.theme-toggle:hover {
  border-color: var(--accent-2);
  background: var(--muted-surface);
}

/* Utility Classes */
.text-mono {
  font-family: var(--font-mono);
}

.text-muted {
  color: var(--text-2);
}

.text-small {
  font-size: 14px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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

/* ==========================================================================
   WordPress Specific
   ========================================================================== */

.alignleft {
  float: left;
  margin-right: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.alignright {
  float: right;
  margin-left: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: var(--sp-3);
}

.wp-caption {
  max-width: 100%;
}

.wp-caption-text {
  font-size: 14px;
  color: var(--text-2);
  margin-top: var(--sp-1);
  font-style: italic;
}

.sticky {
  /* Highlight sticky posts if needed */
}

.bypostauthor {
  /* Highlight post author comments if needed */
}

/* Widget Styles */
.widget {
  margin-bottom: var(--sp-4);
}

.widget-title {
  font-size: 14px;
  color: var(--text-2);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--hairline);
}

.widget ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.widget ul li {
  margin-bottom: var(--sp-1);
}
