/* Side Note Styles - JS Positioning Implementation */

/* 
  Layout Strategy: Absolute Positioning via JS
  1. Main content is centered (max-width 720px).
  2. Side notes are absolutely positioned relative to the container.
  3. JS calculates the 'top' coordinate based on the preceding paragraph.
*/

.wrapper.post .page-content {
  display: block;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  /* Anchor for absolute notes */
  overflow: visible;
  /* Allow notes to hang outside */
}

.wrapper.post .page-content>* {
  max-width: 100%;
}

/* Base Side Note Style */
.side-note {
  box-sizing: border-box;
  background-color: transparent;
  width: 240px;
  z-index: 10;
  padding: 0;
  margin: 0;

  /* Initial State: Hidden until positioned by JS to prevent jump */
  position: absolute;
  visibility: hidden;

  font-size: 0.85em;
  line-height: 1.5;
  color: #e8e8e8;
}

/* Show when positioned */
.side-note.positioned {
  visibility: visible;
  transition: top 0.3s ease;
  /* Smooth re-flow on resize */
}


/* Header */
.side-note .side-note-header {
  font-weight: 700;
  display: block;
  margin-bottom: 0.3rem;
  color: #222;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Content */
.side-note .side-note-content {
  font-style: italic;
  color: #e8e8e8;
}

.side-note .side-note-content p {
  margin: 0;
  margin-bottom: 0.5rem;
}


/* =========================================
   Hacker Style & Offsets
   ========================================= */

/* Left Note */
.side-note.side-note-left {
  left: -260px;
  text-align: right;
  border-right: 2px solid currentColor;
  padding-right: 15px;
}

.side-note.side-note-left::before {
  content: "";
  position: absolute;
  top: 0.65em;
  right: -14px;
  width: 14px;
  height: 2px;
  background-color: currentColor;
  opacity: 0.8;
}

/* Right Note */
.side-note.side-note-right {
  right: -260px;
  text-align: left;
  border-left: 2px solid currentColor;
  padding-left: 15px;
}

.side-note.side-note-right::before {
  content: "";
  position: absolute;
  top: 0.65em;
  left: -14px;
  width: 14px;
  height: 2px;
  background-color: currentColor;
  opacity: 0.8;
}


/* =========================================
   Theme Coloring
   ========================================= */

/* Dark Mode (OS) */
@media (prefers-color-scheme: dark) {
  .side-note {
    color: #cccccc;
  }

  .side-note-header {
    color: #cccccc;
  }

  .side-note-content {
    color: #e8e8e8;
  }

  /* Borders and lines use currentColor */
}

/* Dark Mode (Class) */
.dark .side-note,
body.dark .side-note {
  color: #cccccc !important;
}

.dark .side-note-header,
body.dark .side-note-header {
  color: #cccccc !important;
}

.dark .side-note-content,
body.dark .side-note-content {
  color: #e8e8e8 !important;
}

/* Light Mode (Explicit) */
.light .side-note,
body[data-theme="light"] .side-note {
  color: #cccccc !important;
}

.light .side-note-header,
body[data-theme="light"] .side-note-header {
  color: #cccccc !important;
}

/* Borders and lines use currentColor */


/* =========================================
   Mobile Response
   ========================================= */
@media screen and (max-width: 1260px) {
  .wrapper.post .page-content {
    max-width: 100%;
    padding: 0 1rem;
  }

  .side-note {
    position: static !important;
    /* Disable absolute */
    visibility: visible !important;
    width: 100%;
    margin: 1rem 0 !important;
    padding: 10px !important;
    border: 1px solid rgba(128, 128, 128, 0.2) !important;
    text-align: left !important;
  }

  .side-note.side-note-left {
    border-right: none;
    padding-right: 0;
  }

  .side-note.side-note-right {
    border-left: none;
    padding-left: 0;
  }

  .side-note::before {
    display: none !important;
  }
}