/* Counsel — Core Styles */
/* Aligned with tommenzi.es design system */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Instrument+Serif:ital@0;1&family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&display=swap');

/* === CSS Custom Properties === */
:root {
  /* Palette — light (default) */
  --bg: #f5f0ea;
  --bg-subtle: #ebe5dc;
  --bg-elevated: #faf7f3;
  --text: #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.45);
  --text-tertiary: rgba(26, 26, 26, 0.2);
  --accent: #8a6e47;
  --accent-light: rgba(138, 110, 71, 0.08);
  --accent-mid: rgba(138, 110, 71, 0.2);
  --text-nudge: rgba(26, 26, 26, 0.62);
  --rule: rgba(26, 26, 26, 0.1);

  /* Advisor Colours — desaturated for idle, vivid for active states */
  --color-executive-coach: #5c7a9e;
  --color-therapist: #a68b5b;
  --color-relationship-counsellor: #9e6b7a;
  --color-mindfulness-coach: #5a8a7a;
  --color-creative-director: #7a6a9e;
  --color-devils-advocate: #a67a5b;

  /* Advisor Colours — vivid (for thinking/feedback states) */
  --color-executive-coach-vivid: #2563EB;
  --color-therapist-vivid: #D97706;
  --color-relationship-counsellor-vivid: #DB2777;
  --color-mindfulness-coach-vivid: #059669;
  --color-creative-director-vivid: #7C3AED;
  --color-devils-advocate-vivid: #EA580C;

  /* Orb States */
  --orb-inactive: rgba(26, 26, 26, 0.15);
  --orb-idle-opacity: 0.6;
  --orb-thinking-opacity: 1;
  --orb-feedback-ready-opacity: 1;
  --orb-feedback-read-opacity: 0.8;

  /* Layout */
  --advisory-sidebar-width: 220px;
  --margin-comments-width: 280px;
  --writing-canvas-max-width: 680px;

  /* Typography */
  --font-mono: 'DM Mono', 'Courier New', monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-editor-serif: 'Source Serif 4', 'Instrument Serif', Georgia, serif;
  --font-size-base: 16px;
  --font-size-editor: 1.05rem;
  --line-height-editor: 1.75;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 0.2s;
  --duration-base: 0.3s;
  --duration-slow: 0.5s;
  --duration-entrance: 0.6s;
  --stagger-delay: 70ms;

  /* Borders */
  --radius-sm: 2px;
  --radius-md: 4px;

  /* Atmosphere */
  --grain-opacity: 0.03;
  --grain-blend: multiply;
  --canvas-shadow: inset 0 0 60px rgba(0, 0, 0, 0.03);
  --super-insight-glow: rgba(138, 110, 71, 0.08);
}

/* ── Dark Mode (system preference) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121210;
    --bg-subtle: #1a1916;
    --bg-elevated: #201f1c;
    --text: #e8e6e1;
    --text-secondary: rgba(232, 230, 225, 0.5);
    --text-tertiary: rgba(232, 230, 225, 0.2);
    --accent: #c4a882;
    --accent-light: rgba(196, 168, 130, 0.1);
    --accent-mid: rgba(196, 168, 130, 0.25);
    --text-nudge: rgba(232, 230, 225, 0.53);
    --rule: rgba(232, 230, 225, 0.08);
    --orb-inactive: rgba(232, 230, 225, 0.15);
    --grain-opacity: 0.04;
    --grain-blend: soft-light;
    --canvas-shadow: inset 0 0 60px rgba(0, 0, 0, 0.12);
    --super-insight-glow: rgba(196, 168, 130, 0.1);
  }
}

/* ── Manual theme override (data-theme attribute wins over system preference) ── */
:root[data-theme="dark"] {
  --bg: #121210;
  --bg-subtle: #1a1916;
  --bg-elevated: #201f1c;
  --text: #e8e6e1;
  --text-secondary: rgba(232, 230, 225, 0.5);
  --text-tertiary: rgba(232, 230, 225, 0.2);
  --accent: #c4a882;
  --accent-light: rgba(196, 168, 130, 0.1);
  --accent-mid: rgba(196, 168, 130, 0.25);
  --text-nudge: rgba(232, 230, 225, 0.53);
  --rule: rgba(232, 230, 225, 0.08);
  --orb-inactive: rgba(232, 230, 225, 0.15);
  --grain-opacity: 0.04;
  --grain-blend: soft-light;
  --canvas-shadow: inset 0 0 60px rgba(0, 0, 0, 0.12);
  --super-insight-glow: rgba(196, 168, 130, 0.1);
}

:root[data-theme="light"] {
  --bg: #f5f0ea;
  --bg-subtle: #ebe5dc;
  --bg-elevated: #faf7f3;
  --text: #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.45);
  --text-tertiary: rgba(26, 26, 26, 0.2);
  --accent: #8a6e47;
  --accent-light: rgba(138, 110, 71, 0.08);
  --accent-mid: rgba(138, 110, 71, 0.2);
  --text-nudge: rgba(26, 26, 26, 0.62);
  --rule: rgba(26, 26, 26, 0.1);
  --orb-inactive: rgba(26, 26, 26, 0.15);
}

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

html {
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  line-height: 1.6;
}

/* Paper grain texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* === App Layout === */
.app {
  display: grid;
  grid-template-areas: "council canvas comments";
  grid-template-columns: var(--advisory-sidebar-width) 1fr var(--margin-comments-width);
  grid-template-rows: 1fr;
  min-height: 100vh;
}

.app--no-comments {
  grid-template-areas: "council canvas";
  grid-template-columns: var(--advisory-sidebar-width) 1fr;
}

.app--no-comments .margin-comments {
  display: none;
}

@media (max-width: 1100px) {
  .app {
    grid-template-areas: "council canvas";
    grid-template-columns: var(--advisory-sidebar-width) 1fr;
    grid-template-rows: 1fr;
  }

  .margin-comments {
    display: none;
  }
}

@media (max-width: 680px) {
  .app {
    grid-template-areas: "canvas";
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
}

/* === Advisory Council Sidebar === */
.advisory-council {
  grid-area: council;
  background-color: var(--bg);
  border-right: none;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}

.advisory-council::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent 0%, var(--rule) 15%, var(--rule) 85%, transparent 100%);
}

/* Header: site title + tagline */
.advisory-council__header {
  margin-bottom: var(--space-xl);
  animation: fadeInUp var(--duration-entrance) var(--ease-out) both;
}

.advisory-council__title-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.advisory-council__site-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  transition: color var(--duration-base) ease;
}

.advisory-council__site-title:hover {
  color: var(--accent);
}

.advisory-council__tagline {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  line-height: 1.6;
}

/* === Help Button (?) === */
.counsel-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 400;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.counsel-help-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* === See More inline button === */
.counsel-see-more {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--duration-fast) ease;
}

.counsel-see-more:hover {
  color: var(--text);
}

/* === About Counsel Modal === */
.counsel-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.counsel-modal--open {
  display: flex;
}

.counsel-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.counsel-modal__content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-xl) var(--space-lg);
  z-index: 1;
}

.counsel-modal__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) ease;
}

.counsel-modal__close:hover {
  color: var(--text);
}

.counsel-modal__title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.counsel-modal__text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.counsel-modal__text:last-child {
  margin-bottom: 0;
}

@media (max-width: 680px) {
  .counsel-modal__content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    padding: var(--space-xl) var(--space-md);
    padding-top: calc(var(--space-xl) + var(--space-lg));
  }
}

body.modal-open {
  overflow: hidden;
}

/* Controls (show highlights) — pushed to bottom */
.advisory-council__controls {
  margin-top: auto;
  padding-top: var(--space-lg);
}

/* === Mobile-only elements (hidden on desktop) === */
.advisory-council__handle,
.advisory-council__sheet-label,
.mobile-advisor-overlay,
.mobile-bottom-bar {
  display: none;
}

@media (max-width: 680px) {
  /* Advisory council becomes a fixed bottom sheet on mobile */
  .advisory-council {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 72vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: none;
    border-top: 1px solid var(--rule);
    border-radius: 0.75rem 0.75rem 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 70;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform var(--duration-base) var(--ease-out), visibility 0s linear var(--duration-base);
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    padding: 0 var(--space-md) var(--space-xl);
    background-color: var(--bg);
  }

  .advisory-council::after {
    display: none;
  }

  .advisory-council--sheet-open {
    transform: translateY(0);
    visibility: visible;
    transition: transform var(--duration-base) var(--ease-out), visibility 0s linear 0s;
  }

  /* Sheet drag handle */
  .advisory-council__handle {
    display: block;
    width: 2.5rem;
    height: 3px;
    background: var(--rule);
    border-radius: 2px;
    margin: 0.75rem auto var(--space-sm);
    flex-shrink: 0;
  }

  /* "Advisors" label at top of sheet */
  .advisory-council__sheet-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
  }

  /* Hide "Counsel" title row in the sheet — it lives in the bottom bar */
  .advisory-council__header {
    display: none;
  }

  /* Restore cards to column */
  .advisory-council__cards {
    flex-direction: column !important;
    flex-wrap: nowrap;
    gap: 0 !important;
  }

  /* Controls pinned inside the sheet */
  .advisory-council__controls {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--rule);
    margin-left: 0;
  }

  /* Advisor sheet overlay/scrim */
  .mobile-advisor-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-base) ease;
  }

  .mobile-advisor-overlay--visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Bottom bar: pill + "Counsel ?" footer, always visible */
  .mobile-bottom-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-sm) var(--space-md) calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
    z-index: 50;
    background: var(--bg-elevated);
    border-top: 1px solid var(--rule);
  }

  .mobile-advisors-pill {
    display: flex;
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--rule);
    border-radius: 2rem;
    padding: 0.45rem 1.2rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
  }

  .mobile-advisors-pill:active {
    background: var(--bg);
    color: var(--text);
  }

  .mobile-bottom-bar__footer {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  .mobile-bottom-bar__title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text);
    text-decoration: none;
    transition: color var(--duration-base) ease;
  }

  .mobile-bottom-bar__title:hover {
    color: var(--accent);
  }

  /* Writing canvas: extra bottom padding so content isn't hidden under the bar */
  .writing-canvas {
    padding-bottom: 9rem;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.02);
  }
}

/* === Underline Toggle === */
.underline-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  user-select: none;
}

.underline-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.underline-toggle__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.underline-toggle:hover .underline-toggle__label {
  color: var(--text);
}

.advisory-council__cards {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* === Advisor Card (Nav Row Design) === */
.advisor-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.45rem 0.35rem;
  margin: 0 -0.35rem;
  cursor: pointer;
  transition: opacity var(--duration-base) var(--ease-out), background var(--duration-fast) var(--ease-out);
  user-select: none;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  width: calc(100% + 0.7rem);
  animation: advisorCardEnter var(--duration-entrance) var(--ease-out) both;
}

.advisor-card:nth-child(1) { animation-delay: calc(var(--stagger-delay) * 0); }
.advisor-card:nth-child(2) { animation-delay: calc(var(--stagger-delay) * 1); }
.advisor-card:nth-child(3) { animation-delay: calc(var(--stagger-delay) * 2); }
.advisor-card:nth-child(4) { animation-delay: calc(var(--stagger-delay) * 3); }
.advisor-card:nth-child(5) { animation-delay: calc(var(--stagger-delay) * 4); }
.advisor-card:nth-child(6) { animation-delay: calc(var(--stagger-delay) * 5); }

.advisor-card:hover {
  background: var(--accent-light);
  border-color: transparent;
  transform: none;
}

.advisor-card:hover .advisor-card__orb {
  transform: scale(1.15);
}

.advisor-card--inactive {
  opacity: 0.35;
}

.advisor-card--inactive .advisor-card__orb {
  transform: scale(0.85);
}

.advisor-card--inactive:hover {
  opacity: 0.6;
  background: var(--accent-light);
  border-color: transparent;
}

/* === Orb === */
.advisor-card__orb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transition: all var(--duration-base) var(--ease-out);
  flex-shrink: 0;
}

.advisor-card__orb--inactive {
  background-color: var(--orb-inactive);
  box-shadow: none;
}

.advisor-card__orb--idle {
  opacity: var(--orb-idle-opacity);
  box-shadow: 0 0 8px currentColor, 0 0 3px currentColor;
}

.advisor-card__orb--thinking {
  opacity: var(--orb-thinking-opacity);
  animation: orb-pulse 1.2s ease-in-out infinite;
}

.advisor-card__orb--feedback-ready {
  opacity: var(--orb-feedback-ready-opacity);
  animation: orb-beacon 1.8s ease-in-out infinite;
}

.advisor-card__orb--feedback-read {
  opacity: var(--orb-feedback-read-opacity);
  box-shadow: 0 0 4px currentColor;
}

@keyframes orb-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 6px currentColor;
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 0 12px currentColor;
  }
}

@keyframes orb-beacon {
  0%, 100% {
    box-shadow: 0 0 6px currentColor;
  }
  50% {
    box-shadow: 0 0 14px currentColor, 0 0 20px currentColor;
  }
}

/* === Advisor Name === */
.advisor-card__name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text);
  letter-spacing: 0.02em;
  text-align: left;
  line-height: 1.2;
  transition: color var(--duration-base) ease;
}

.advisor-card:hover .advisor-card__name {
  color: var(--accent);
}

.advisor-card--inactive .advisor-card__name {
  color: var(--text);
}

/* === Writing Canvas === */
.writing-canvas {
  grid-area: canvas;
  display: flex;
  justify-content: center;
  padding: var(--space-xl) var(--space-lg);
  background-color: var(--bg-elevated);
  overflow-y: auto;
  min-height: 0;
  box-shadow: var(--canvas-shadow);
}

.writing-canvas__container {
  width: 100%;
  max-width: var(--writing-canvas-max-width);
  position: relative;
  animation: fadeInUp var(--duration-entrance) var(--ease-out) both;
  animation-delay: calc(var(--stagger-delay) * 3);
}

/* === Nudge Prompt === */
.nudge-prompt {
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.nudge-prompt:not(.nudge-prompt--hidden) {
  animation: nudgeBreathe 4s ease-in-out 1s infinite;
}

.nudge-prompt--hidden {
  opacity: 0;
  transform: translateY(8px);
}

.nudge-prompt__text {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.6;
  color: var(--text-nudge);
  font-style: italic;
}

/* === Editor === */
.editor {
  font-family: var(--font-editor-serif);
  font-size: var(--font-size-editor);
  line-height: var(--line-height-editor);
  color: var(--text);
  min-height: 60vh;
  outline: none;
  word-wrap: break-word;
  white-space: pre-wrap;
  font-optical-sizing: auto;
}

.editor:focus {
  outline: none;
}

/* === Margin Comments === */
.margin-comments {
  grid-area: comments;
  background-color: var(--bg-subtle);
  border-left: none;
  padding: var(--space-xl) var(--space-md);
  overflow-y: auto;
  position: relative;
}

.margin-comments::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent 0%, var(--rule) 15%, var(--rule) 85%, transparent 100%);
  z-index: 1;
}

/* === Comment Card === */
.comment-card {
  background-color: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--rule);
  border-left-width: 3px;
  border-left-color: var(--text-tertiary);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.comment-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.comment-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.comment-card__advisor {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.comment-card__type {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  background: var(--accent-light);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.comment-card__content {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 300;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* === Text Underlines === */
.text-underline {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.text-underline:hover {
  background-color: var(--accent-light);
}

.text-underline--keyboard-focus {
  background-color: var(--accent-light);
  outline: 1px solid var(--accent-mid);
  border-radius: 1px;
}

.text-underline--super-insight {
  text-decoration-thickness: 2px;
  text-decoration-style: wavy;
  text-decoration-color: var(--accent);
  animation: superInsightGlow 2.5s ease-in-out infinite;
}

/* === Margin Comments Container === */
.margin-comments__container {
  position: absolute;
  left: 0;
  right: 0;
  animation: commentSlideIn var(--duration-fast) var(--ease-out);
}

.margin-comments__container .comment-card {
  animation: commentSlideIn var(--duration-fast) var(--ease-out) both;
}

.margin-comments__container .comment-card:nth-child(2) { animation-delay: 50ms; }
.margin-comments__container .comment-card:nth-child(3) { animation-delay: 100ms; }
.margin-comments__container .comment-card:nth-child(4) { animation-delay: 150ms; }
.margin-comments__container .comment-card:nth-child(5) { animation-delay: 200ms; }
.margin-comments__container .comment-card:nth-child(6) { animation-delay: 250ms; }

@keyframes commentSlideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* === Super-Insight Header === */
.super-insight-header {
  background: linear-gradient(135deg, var(--accent-light), transparent, var(--accent-light));
  background-size: 200% 200%;
  animation: superInsightShimmer 3s ease-in-out infinite;
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
}

.super-insight-header__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}

.super-insight-header__count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* === Mobile Comment Panel === */
.mobile-comment-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-elevated);
  border-top: 1px solid var(--rule);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(100%);
  transition: transform var(--duration-base) var(--ease-out);
  z-index: 100;
  max-height: 60vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mobile-comment-panel--visible {
  transform: translateY(0);
}

.mobile-comment-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.mobile-comment-panel__title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

.mobile-comment-panel__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.mobile-comment-panel__close:hover {
  color: var(--text);
}

.mobile-comment-panel__content {
  padding: var(--space-md);
  overflow-y: auto;
  flex: 1;
}

.mobile-comment-panel__content .comment-card {
  margin-bottom: var(--space-sm);
}

.mobile-comment-panel__content .comment-card:last-child {
  margin-bottom: 0;
}

/* === Super-Insight Badge === */
.super-insight-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  color: var(--bg);
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-right: var(--space-xs);
  box-shadow: 0 1px 4px rgba(138, 110, 71, 0.3);
}

/* === Body state for mobile panel === */
body.mobile-panel-open {
  overflow: hidden;
}

/* === Utility Classes === */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Entrance & Motion Keyframes === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes advisorCardEnter {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes nudgeBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes superInsightGlow {
  0%, 100% { background-color: transparent; }
  50% { background-color: var(--super-insight-glow); }
}

@keyframes superInsightShimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 200%; }
}

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