/* ansatz / legacy
 *
 * surviving rules from the pre-ansatz sanctuary CSS, kept while
 * components (blog, lab, project list, etc.) are gradually retoned
 * into the ansatz design system. globals (resets, body, headings)
 * are gone — base.css owns those. the matrix-rain / observer-field /
 * three-panel terminal layout is gone with the rewrite.
 *
 * the :root block here aliases the original sanctuary custom
 * properties onto ansatz tokens so existing rules retone
 * automatically. as components are fully migrated into the ansatz
 * CSS modules, the corresponding rules here can be deleted.
 */

:root {
  --bg-deep:       var(--void);
  --bg-panel:      var(--void-2);
  --border-dim:    var(--hairline);
  --text-main:     var(--ink);
  --text-dim:      var(--ink-dim);
  --accent-gold:   var(--bronze);
  --accent-purple: var(--moss);
  --accent-green:  var(--celadon);
  --accent-red:    var(--vermilion);
  --font-mono:     var(--mono);
}

/* glow utilities, retoned to bronze / indigo / celadon. dropped the
 * pulse-* keyframes; the new aesthetic doesn't pulse. */
.gold-glow {
  color: var(--accent-gold);
  text-shadow: 0 0 14px var(--bronze-glow);
}
.purple-glow {
  color: var(--accent-purple);
  text-shadow: 0 0 14px rgba(125, 155, 86, 0.45);
}
.green-glow {
  color: var(--accent-green);
  text-shadow: 0 0 14px rgba(127, 160, 122, 0.45);
}



/* Components */
.panel-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-dim);
  color: var(--accent-gold);
}

.scroll-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.tag-pill {
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid var(--border-dim);
  text-transform: uppercase;
  margin-right: 5px;
}

.tag-surface {
  color: var(--accent-green);
  border-color: var(--accent-green);
}

.tag-deep {
  color: var(--accent-purple);
  border-color: var(--accent-purple);
}

.tag-pill.tag-selected {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.tag-pill:hover {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
}

pre {
  margin: 0;
  font-family: inherit;
}

/* Log Entry Styling */
.log-entry {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(51, 51, 51, 0.5);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry p {
  margin: 5px 0;
  line-height: 1.6;
}

.italic {
  font-style: italic;
  color: var(--text-dim);
}

/* Typing Animation */
@keyframes blink-cursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.typing-cursor {
  animation: blink-cursor 0.8s infinite;
  color: var(--accent-gold);
  margin-left: 2px;
}

.typing-cursor-hidden {
  display: none;
}

/* Typewriter Component */
.typewriter {
  display: inline-flex;
  align-items: baseline;
}

.typewriter-text {
  white-space: pre-wrap;
}

.typewriter-cursor {
  color: var(--accent-gold);
  margin-left: 1px;
}

.typewriter-cursor-blink {
  animation: blink-cursor 0.6s step-end infinite;
}

.typewriter-cursor-hidden {
  visibility: hidden;
}

/* Branch Item Component */
.branch-item {
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Stats Row */
.stats-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 0.8rem;
}

/* Section Styling */
.section-divider {
  margin-top: 40px;
  border-top: 1px solid var(--border-dim);
  padding-top: 20px;
}

.section-divider h3 {
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.section-header {
  margin-top: 20px;
  margin-bottom: 10px;
}

.section-subtext {
  font-size: 0.8rem;
  margin-top: 10px;
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

@media (max-width: 600px) {
  .header-bar {
    font-size: 0.7rem;
    padding: 0 10px;
  }

  .scroll-content {
    padding: 15px;
  }

  .panel-header {
    padding: 10px 15px;
  }
}

@media (max-width: 600px) {
  .music-player {
    width: 100%;
  }

  .music-player-progress-container {
    flex: 1;
    min-width: 80px;
  }
}

/* Project List */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-dim);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s ease;
  background: transparent;
}

.project-item:hover {
  border-color: var(--accent-purple);
  background: rgba(189, 147, 249, 0.05);
}

.project-item-recent {
  border-color: var(--accent-gold);
  animation: pulse-project 3s ease-in-out infinite;
}

.project-item-recent .project-name {
  color: var(--accent-gold);
}

.project-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.forge-badge {
  font-size: 0.6rem;
  padding: 2px 5px;
  border-radius: 2px;
  font-weight: bold;
  text-transform: uppercase;
}

.forge-github {
  background: rgba(255, 255, 255, 0.1);
  color: #f0f0f0;
}

.forge-gitlab {
  background: rgba(252, 109, 38, 0.2);
  color: #fc6d26;
}

.forge-codeberg {
  background: rgba(47, 129, 247, 0.2);
  color: #2f81f7;
}

.project-time {
  font-size: 0.7rem;
  color: var(--text-dim);
  min-width: 50px;
  text-align: right;
}

/* Blog Styles */
.blog-container {
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--s-8) var(--s-4) var(--s-24);
}

.blog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-dim);
}

.blog-header h1 {
  margin: 0;
  font-size: var(--t-display-m);
}

.blog-header-links {
  display: flex;
  gap: var(--s-4);
}

.blog-back-link,
.blog-rss-link {
  color: var(--accent-purple);
  text-decoration: none;
  border: none;
  font-family: var(--sans);
  font-size: var(--t-tiny);
  letter-spacing: 0.2em;
  transition: text-shadow 0.2s ease;
}

.blog-back-link:hover,
.blog-rss-link:hover {
  color: var(--accent-gold);
  text-shadow: 0 0 12px var(--bronze-glow);
}

/* Post List */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-preview {
  display: block;
  padding: 20px;
  border: 1px solid var(--border-dim);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.post-preview:hover {
  border-color: var(--accent-gold);
  background: var(--bg-panel);
}

.post-title {
  color: var(--accent-gold);
  margin: 0 0 10px 0;
  font-size: var(--t-display-s);
}

.blog-post .post-title {
  font-size: var(--t-display-m);
  letter-spacing: 0.12em;
}

.post-date {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.post-meta-row {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

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

.post-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  background: var(--moss-faint);
  color: var(--accent-purple);
  border: 1px solid var(--moss-deep);
  border-radius: 3px;
}

.post-summary {
  margin: 0;
  color: var(--text-main);
  line-height: 1.6;
}

/* Individual Post */
.blog-post {
  line-height: 1.8;
}

.post-subtitle {
  font-family: var(--serif);
  font-size: var(--t-lead);
  font-style: italic;
  color: var(--text-dim);
  margin: 0 0 var(--s-4);
}

.post-body {
  color: var(--text-main);
  /* long urls and unbroken tokens wrap instead of pushing the column
   * sideways. `anywhere` on links so a bare url breaks mid-token. */
  overflow-wrap: break-word;
}

.post-body a,
.post-body code {
  overflow-wrap: anywhere;
}

.post-body h1 {
  color: var(--accent-gold);
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 10px;
  margin-top: 40px;
  margin-bottom: var(--s-4);
  font-size: var(--t-display-s);
  letter-spacing: 0.08em;
  text-transform: none;
}

.post-body h2 {
  color: var(--accent-gold);
  margin-top: 40px;
  margin-bottom: var(--s-3);
  font-size: var(--t-lead);
  letter-spacing: 0.06em;
}

.post-body h3 {
  color: var(--accent-purple);
  margin-top: 30px;
  margin-bottom: var(--s-2);
  font-size: var(--t-body);
}

.post-body a {
  color: var(--accent-purple);
  text-decoration: none;
  border-bottom: 1px solid var(--moss-deep);
}

.post-body a:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.post-body code {
  background: var(--void-3);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.post-body pre {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  padding: 15px;
  overflow-x: auto;
  margin: 20px 0;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body blockquote {
  border-left: 3px solid var(--moss-deep);
  margin: 20px 0;
  padding-left: 20px;
  color: var(--text-dim);
  font-style: italic;
}

.post-body ul, .post-body ol {
  padding-left: 25px;
}

.post-body li {
  margin: 8px 0;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-dim);
}

/* figures: a paragraph holding one image, caption from the image title.
 * no plate behind the image, so a transparent png shows the void
 * through its holes. */
.post-figure {
  margin: var(--s-8) 0;
  text-align: center;
}

.post-figure img {
  max-width: 100%;
  max-height: 24rem;
  width: auto;
  height: auto;
  border: none;
}

.post-figure figcaption {
  margin-top: var(--s-2);
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--t-small);
  line-height: 1.5;
  color: var(--text-dim);
}

/* footnotes: the marker carries the note, so hovering (or focusing, for
 * touch and keyboard) reads it without leaving the paragraph. */
.post-note-ref {
  position: relative;
  font-size: 0.7em;
  line-height: 0;
  outline: none;
}

.post-body .post-note-ref a {
  color: var(--accent-purple);
  border: none;
  padding-left: 0.1em;
}

.post-note-tip {
  position: absolute;
  bottom: 1.6em;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-tooltip);
  display: none;
  width: max-content;
  max-width: min(24rem, 70vw);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-floating);
  border: 1px solid var(--hairline-warm);
  font-family: var(--serif);
  font-size: var(--t-small);
  font-style: normal;
  line-height: 1.5;
  text-align: left;
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.post-note-ref:hover .post-note-tip,
.post-note-ref:focus .post-note-tip,
.post-note-ref:focus-within .post-note-tip {
  display: block;
}

.post-notes {
  margin-top: var(--s-16);
  padding-top: var(--s-6);
  border-top: 1px solid var(--border-dim);
  font-size: var(--t-small);
  line-height: 1.6;
  color: var(--text-dim);
}

.post-notes-title {
  font-family: var(--sans);
  font-size: var(--t-tiny);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--s-4);
}

.post-notes ol {
  padding-left: 1.5em;
}

.post-notes li {
  margin: var(--s-2) 0;
}

.post-body .post-note-back {
  color: var(--text-faint);
  border: none;
}

.post-body .post-note-back:hover {
  color: var(--accent-gold);
}

/* folded sections: <details> in a post. */
.post-body details {
  margin: var(--s-8) 0;
  padding: var(--s-4) var(--s-6);
  border: 1px solid var(--border-dim);
}

.post-body summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: var(--t-tiny);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent-gold);
}

.post-body summary:hover {
  text-shadow: 0 0 12px var(--bronze-glow);
}

.post-body details[open] summary {
  margin-bottom: var(--s-4);
}

/* Image wrapping classes for use in markdown HTML */
.image-left {
  float: left;
  margin: 0 20px 15px 0;
  max-width: 45%;
}

.image-right {
  float: right;
  margin: 0 0 15px 20px;
  max-width: 45%;
}

.image-left img,
.image-right img {
  width: 100%;
}

.image-left .caption,
.image-right .caption {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 5px;
}

.image-center {
  text-align: center;
  margin: 30px 0;
}

.image-center img {
  max-width: 80%;
}

.image-full {
  margin: 30px -20px;
}

.image-full img {
  width: 100%;
  max-width: none;
}

/* Clear floats after images */
.post-body::after {
  content: "";
  display: table;
  clear: both;
}

/* Post not found */
.post-not-found {
  text-align: center;
  padding: 60px 20px;
}

.post-not-found h1 {
  color: var(--accent-gold);
}

.post-not-found a {
  color: var(--accent-purple);
}

/* Reading progress bar */
.reading-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 100;
  background: transparent;
}

.reading-progress-bar {
  height: 100%;
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--bronze-glow);
  transition: width 50ms linear;
}

/* Quantum Lab */
.lab-container {
  height: 100vh;
  background: var(--bg-deep);
  padding: 40px 20px;
  max-width: 900px;
  margin: 0 auto;
  overflow-y: auto;
}

.lab-header {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-dim);
}

.lab-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.lab-subtitle {
  font-size: 0.85rem;
  margin: 4px 0;
  color: var(--text-main);
}

.lab-notice {
  border: 1px solid rgba(255, 85, 85, 0.3);
  padding: 12px 16px;
  margin-bottom: 30px;
  background: rgba(255, 85, 85, 0.03);
}

.lab-notice p {
  margin: 0;
  font-size: 0.8rem;
}

.lab-log h2 {
  margin-bottom: 20px;
  font-size: 1rem;
}

/* Circuit cards */
.circuit-card {
  border: 1px solid var(--border-dim);
  margin-bottom: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-panel);
}

.circuit-card:hover {
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.1);
}

.circuit-card-expanded {
  border-color: var(--accent-purple);
  box-shadow: 0 0 30px rgba(189, 147, 249, 0.15);
}

.circuit-card-expanded:hover {
  border-color: var(--accent-purple);
}

.circuit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.circuit-card-header h3 {
  font-size: 1rem;
  letter-spacing: 3px;
}

/* Status badges */
.status-badge {
  font-size: 0.7rem;
  padding: 3px 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
}

.status-completed {
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}

.status-running {
  color: var(--accent-purple);
  border: 1px solid var(--accent-purple);
  animation: pulse-purple 2s infinite ease-in-out;
}

.status-failed {
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
  text-shadow: 0 0 8px rgba(255, 85, 85, 0.5);
}

/* Circuit card summary */
.circuit-card-summary {
  margin-bottom: 16px;
}

.circuit-card-summary p {
  margin: 3px 0;
  font-size: 0.8rem;
}

/* Gate breakdown bars */
.circuit-card-gates {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gate-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
}

.gate-bar-label {
  width: 45px;
  color: var(--accent-purple);
  text-align: right;
  flex-shrink: 0;
}

.gate-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(51, 51, 51, 0.5);
  position: relative;
  overflow: hidden;
}

.gate-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-gold));
  box-shadow: 0 0 8px rgba(189, 147, 249, 0.4);
  transition: width 0.6s ease;
}

.gate-bar-count {
  width: 40px;
  text-align: right;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Expanded detail view */
.circuit-detail {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-dim);
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section h4 {
  font-size: 0.85rem;
  margin-bottom: 14px;
  letter-spacing: 2px;
}

/* Metadata grid */
.meta-grid {
  display: flex;
  gap: 16px;
  padding: 4px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(51, 51, 51, 0.3);
}

.meta-key {
  width: 80px;
  color: var(--text-dim);
  text-align: right;
  flex-shrink: 0;
}

.meta-val {
  color: var(--text-main);
  word-break: break-all;
}

/* Probability distribution chart */
.prob-chart {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.prob-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
}

.prob-state {
  width: 140px;
  text-align: right;
  font-family: var(--font-mono);
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.prob-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(51, 51, 51, 0.4);
  position: relative;
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  background: linear-gradient(90deg,
    rgba(0, 255, 65, 0.7),
    rgba(189, 147, 249, 0.9),
    rgba(255, 215, 0, 0.8)
  );
  box-shadow:
    0 0 6px rgba(189, 147, 249, 0.5),
    0 0 12px rgba(0, 255, 65, 0.2);
  transition: width 0.8s ease;
}

.prob-pct {
  width: 50px;
  text-align: right;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.prob-footer {
  margin-top: 12px;
  font-size: 0.8rem;
}

/* Circuit diagram */
.circuit-schematic-note {
  font-size: 0.72rem;
  margin: 0 0 8px 0;
}

.circuit-diagram-wrap {
  overflow-x: auto;
  margin: 4px 0;
  border: 1px solid rgba(51, 51, 51, 0.3);
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.circuit-diagram {
  width: 100%;
  display: block;
}

.cd-wire {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
}

.cd-label {
  fill: rgba(255, 255, 255, 0.3);
  font-size: 9px;
  font-family: 'Space Mono', 'Fira Code', monospace;
}

.cd-1q-box {
  fill: rgba(189, 147, 249, 0.08);
  stroke: rgba(189, 147, 249, 0.45);
  stroke-width: 1;
}

.cd-1q-text {
  fill: rgba(189, 147, 249, 0.85);
  font-size: 7.5px;
  font-family: 'Space Mono', 'Fira Code', monospace;
  font-weight: bold;
}

.cd-2q-line {
  stroke: rgba(0, 255, 65, 0.35);
  stroke-width: 1.5;
}

.cd-2q-dot {
  fill: rgba(0, 255, 65, 0.6);
}

.cd-ellipsis {
  fill: rgba(255, 255, 255, 0.25);
  font-size: 18px;
}

.circuit-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.circuit-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  flex-shrink: 0;
}

.legend-1q {
  width: 14px;
  height: 9px;
  border: 1px solid rgba(189, 147, 249, 0.5);
  background: rgba(189, 147, 249, 0.1);
  border-radius: 1px;
}

.legend-2q {
  color: rgba(0, 255, 65, 0.6);
  font-size: 0.6rem;
  letter-spacing: -1px;
}

/* Responsive lab */
@media (max-width: 600px) {
  .lab-container {
    padding: 20px 15px;
  }

  .lab-header-row {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .prob-state {
    width: 100px;
    font-size: 0.65rem;
  }

  .meta-key {
    width: 60px;
  }
}

/* Responsive blog */
@media (max-width: 600px) {
  .blog-container {
    padding: 20px 15px;
  }

  .blog-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .image-left,
  .image-right {
    float: none;
    max-width: 100%;
    margin: 20px 0;
  }
}
