:root {
  /* PERFECT VERTICAL RHYTHM VARIABLES */
  --grid-size: 32px;
  /* Strict grid height for everything */
  --baseline-offset: 31px;
  /* Positions the line at the exact bottom of the text row */

  --grid-line: rgba(43, 58, 85, 0.12);
  /* Faint navy/grey grid lines matching the new notebook image */
  --paper-bg: #fdfaf0;
  /* Warm cream paper background matching the new notebook image */
  --ink-navy: #2b3a55;
  /* The dark navy color for the notebook borders */

  /* Ink Colors for Notes */
  --ink-black: #1e293b;
  --ink-blue: #2563eb;
  --ink-red: #dc2626;
  --ink-green: #059669;

  /* Highlighters (Pastels) */
  --hl-yellow: #fef08a;
  --hl-pink: #fecdd3;
  --hl-blue: #bfdbfe;
  --hl-green: #a7f3d0;
}

/* * STRICT CSS RESET 
      * To keep text on the grid, we must eliminate all default margins/paddings.
      */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--paper-bg);
  color: var(--ink-black);
  font-family: 'Comic Neue', cursive, sans-serif;
  font-size: 18px;
  line-height: var(--grid-size);
  padding: 40px 20px 80px 20px;
  display: flex;
  justify-content: center;
}

/* NOTEBOOK LAYOUT (Replicating the uploaded image) */
.notebook-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
}

/* The Date & Days Header (Outside the box) */
.notebook-header {
  font-family: 'Space Mono', monospace;
  color: var(--ink-navy);
  font-size: 14px;
  margin-bottom: 12px;
  padding-left: 12px;
  width: 240px;
  /* Fixed width to perfectly align both rows */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.date-label {
  letter-spacing: 6px;
}

.date-value {
  letter-spacing: 1px;
}

.days-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.days-row span {
  text-align: center;
  width: 24px;
  text-transform: lowercase;
}

.days-row span.active {
  background-color: var(--hl-yellow);
  border-radius: 4px;
  font-weight: bold;
  color: var(--ink-black);
  padding: 2px 0;
  margin: -2px 0;
  /* Offsets the padding to keep alignment strict */
}

/* The Main Bordered Box */
.notebook-box {
  border: 1px solid var(--ink-navy);
  background-color: transparent;
  min-height: 800px;
  display: flex;
  flex-direction: column;
}

/* The Title Row (Inside the box, top) */
.notebook-title-row {
  border-bottom: 1px solid var(--ink-navy);
  padding: 6px 12px;
  font-family: 'Space Mono', monospace;
  color: var(--ink-navy);
  font-size: 16px;
  letter-spacing: 1px;
  /* Ensures this row doesn't break the grid math for the content below */
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.index-link {
  font-family: 'Space Mono', monospace;
  color: var(--ink-navy);
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
  border: 1px solid var(--ink-navy);
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: lowercase;
  transition: background-color 0.2s, color 0.2s;
  letter-spacing: normal;
}

.index-link:hover {
  background-color: var(--ink-navy);
  color: var(--paper-bg);
}

/* The Grid Area (Where the notes go) */
.notebook-grid-content {
  flex: 1;
  /* The Graph Paper Grid applied ONLY inside the box */
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: 0 var(--baseline-offset);

  /* Padding ensures text aligns to the background grid */
  padding: var(--grid-size) 32px calc(var(--grid-size) * 3) 32px;
}

/* * VERTICAL RHYTHM TYPOGRAPHY inside the grid */
h1,
h2,
h3,
p,
ul,
ol,
li,
div {
  margin: 0;
  padding: 0;
}

p {
  margin-bottom: var(--grid-size);
  /* 1 blank line below paragraphs */
}

h1 {
  font-family: 'Patrick Hand', cursive;
  font-size: 42px;
  color: var(--ink-black);
  line-height: calc(var(--grid-size) * 2);
  /* Takes exactly 2 lines */
  margin-bottom: var(--grid-size);
  text-align: center;
}

h2 {
  font-family: 'Patrick Hand', cursive;
  font-size: 28px;
  color: var(--ink-blue);
  line-height: var(--grid-size);
  /* Takes exactly 1 line */
  margin-bottom: var(--grid-size);
}

/* Lists */
ul,
ol {
  margin-bottom: var(--grid-size);
  padding-left: 32px;
  list-style-type: none;
}

li {
  position: relative;
  margin-bottom: 0;
}

ul li::before {
  content: "•";
  position: absolute;
  left: -20px;
  color: var(--ink-blue);
  font-weight: bold;
}

ol {
  counter-reset: note-counter;
}

ol li::before {
  counter-increment: note-counter;
  content: counter(note-counter) ".";
  position: absolute;
  left: -24px;
  color: var(--ink-red);
  font-family: 'Patrick Hand', cursive;
  font-weight: bold;
}

/* Highlighter Effects */
.hl-yellow,
.hl-pink,
.hl-blue,
.hl-green {
  border-radius: 2px;
}

.hl-yellow {
  background-color: var(--hl-yellow);
}

.hl-pink {
  background-color: var(--hl-pink);
}

.hl-blue {
  background-color: var(--hl-blue);
}

.hl-green {
  background-color: var(--hl-green);
}

/* Boxes & Callouts */
.callout-box {
  box-shadow: inset 0 0 0 2px var(--ink-blue);
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  padding: var(--grid-size) 32px var(--grid-size) 32px;
  margin-bottom: var(--grid-size);
}

.callout-box.red-ink {
  box-shadow: inset 0 0 0 2px var(--ink-red);
  background-color: rgba(254, 242, 242, 0.7);
}

/* Text colors */
.text-blue {
  color: var(--ink-blue);
}

.text-red {
  color: var(--ink-red);
}

.text-green {
  color: var(--ink-green);
}

.bold {
  font-weight: 700;
}

/* Arrows */
.arrow {
  color: var(--ink-red);
  font-family: 'Patrick Hand', cursive;
  font-weight: bold;
  margin-right: 8px;
}

/* Small annotations */
.annotation {
  display: block;
  color: var(--ink-red);
  font-family: 'Patrick Hand', cursive;
  text-align: center;
  margin-bottom: var(--grid-size);
}

/* Handwritten Utilities */
.formula-text {
  font-family: 'Patrick Hand', cursive;
  font-size: 26px;
  text-align: center;
  margin-bottom: var(--grid-size);
  line-height: calc(var(--grid-size) * 2);
}

.handwritten-highlight {
  font-family: 'Patrick Hand', cursive;
  font-size: 26px;
  font-weight: bold;
  line-height: var(--grid-size);
}

/* Phase Groupings on Index Page */
.phase-container {
  position: relative;
  margin-right: 36px;
}

.phase-content {
  position: relative;
  border-right: 2px solid var(--ink-red);
  padding-right: 24px;
}

/* Horizontal ticks at the top and bottom to represent range */
.phase-content::before,
.phase-content::after {
  content: "";
  position: absolute;
  right: -2px; /* Aligns with the 2px border */
  width: 40px;
  height: 2px;
  background-color: var(--ink-red);
}

.phase-content::before {
  top: 0;
}

.phase-content::after {
  bottom: 0;
}

.phase-label {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
  color: var(--ink-red);
  background-color: var(--hl-yellow);
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: lowercase;
  white-space: nowrap;
  letter-spacing: 1px;
  z-index: 2;
}

/* Sidebar Navigation */
.nav-sidebar {
  position: absolute;
  top: 140px;
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink-navy);
  font-weight: normal;
  width: 180px;
  line-height: 1.5;
}
.nav-sidebar:hover {
  text-decoration: underline;
  color: var(--ink-red);
}
.nav-prev {
  right: 100%;
  margin-right: 40px;
  text-align: right;
}
.nav-next {
  left: 100%;
  margin-left: 40px;
  text-align: left;
}

@media (max-width: 1200px) {
  .notebook-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .nav-sidebar {
    position: static;
    width: 48%;
    margin: 20px 0 0 0;
  }
  .nav-prev {
    order: 3;
    text-align: left;
  }
  .nav-next {
    order: 4;
    text-align: right;
  }
  .notebook-header {
    order: 1;
    width: 100%;
  }
  .notebook-box {
    order: 2;
    width: 100%;
  }
}

@media (max-width: 600px) {
  body {
    padding: 10px 5px;
  }

  .nav-sidebar {
    width: 100%;
    margin-bottom: 12px;
  }
  .nav-prev, .nav-next {
    text-align: center;
  }

  .notebook-grid-content {
    padding: var(--grid-size) 16px;
  }

  h1 {
    font-size: 28px;
    line-height: var(--grid-size);
  }

  .notebook-title-row {
    font-size: 13px;
    padding: 6px 8px;
  }

  .title-prefix {
    display: none;
  }


  .formula-text {
    font-size: 20px;
    line-height: var(--grid-size);
  }

  .handwritten-highlight {
    font-size: 20px;
  }

  .phase-container {
    margin-right: 22px;
  }

  .phase-content {
    padding-right: 12px;
  }

  .phase-label {
    right: 0;
    font-size: 16px;
    padding: 2px 6px;
  }
}

