/* =========================================================================
   Saige Circle — Life OS Student Manual Styles
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;700&family=DM+Mono:wght@300;400&display=swap');

:root {
  --nw-teal:        #8CA486;
  --nw-teal-800:    #5F735A;
  --nw-teal-100:    #E5EADD;
  --nw-teal-50:     #F5F7F0;
  --nw-terracotta:  #B97455;
  --nw-terracotta-800: #8F563F;
  --nw-amber:       #B8943B;
  --nw-marigold:    #D7C38D;
  --nw-sage-mist:   #B8BAB0;
  --nw-ink:         #1F1E1E;
  --nw-ink-500:     #4A4948;
  --nw-ink-300:     #5F5E5C;
  --nw-paper:       #FDFCF9;
  --nw-paper-alt:   #F5F3EC;
  --border:         #D9DACF;

  --font-brand: 'DM Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(26,26,26,0.06), 0 1px 2px rgba(26,26,26,0.04);
  --shadow-md: 0 4px 10px rgba(26,26,26,0.06), 0 2px 4px rgba(26,26,26,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* Dark mode overrides */
[data-theme="dark"] {
  --nw-ink:         #F1EFE8;
  --nw-ink-500:     #C8C2B8;
  --nw-ink-300:     #958F86;
  --nw-paper:       #1F1E1E;
  --nw-paper-alt:   #2C2A27;
  --border:         #454239;
  --nw-teal-50:     #283126;
  --nw-teal-100:    #384534;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-brand);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.7;
  color: var(--nw-ink);
  background: var(--nw-paper);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s ease, color 0.3s ease;
}

/* -------------------------------------------------------------------------
   Navigation
   ------------------------------------------------------------------------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(253, 252, 249, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

[data-theme="dark"] .topnav {
  background: rgba(28, 28, 26, 0.92);
}

.topnav-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  min-width: 0;
}

.topnav .brand {
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.01em;
  color: var(--nw-teal);
  text-decoration: none;
  flex: 0 0 auto;
}

.topnav .brand span {
  color: var(--nw-ink-500);
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-links a {
  text-decoration: none;
  font-weight: 400;
  font-size: 13px;
  color: var(--nw-ink-500);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--nw-teal);
  background: var(--nw-teal-50);
}

.nav-links a.active {
  color: var(--nw-paper);
  background: var(--nw-teal);
}

/* Dark mode toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--nw-ink-500);
  padding: 6px;
  border-radius: var(--radius-md);
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.theme-toggle:hover {
  background: var(--nw-paper-alt);
  color: var(--nw-teal);
}

/* -------------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------------- */
.page-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* -------------------------------------------------------------------------
   Typography
   ------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-brand);
  color: var(--nw-ink);
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 1.4em 0 0.5em;
}

h1 {
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-top: 0;
}

h2 {
  font-size: clamp(25px, 3.2vw, 34px);
  font-weight: 300;
  margin-top: 1.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: clamp(20px, 2.5vw, 26px);
  font-weight: 400;
  margin-top: 1.5em;
}

h4 {
  font-size: 20px;
  font-weight: 400;
  margin-top: 1.4em;
}

h5 {
  font-size: 18px;
  font-weight: 400;
  margin-top: 1.3em;
}

h6 {
  font-size: 15px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nw-ink-500);
  margin-top: 1.2em;
}

p {
  margin: 0.9em 0;
  text-wrap: pretty;
}

a {
  color: var(--nw-teal);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: all 0.15s ease;
}
a:hover {
  color: var(--nw-teal-800);
  text-decoration-thickness: 2px;
}

/* -------------------------------------------------------------------------
   Lists
   ------------------------------------------------------------------------- */
ul, ol {
  margin: 0.8em 0;
  padding-left: 1.6em;
}

li {
  margin: 0.35em 0;
}

li::marker {
  color: var(--nw-teal);
}

/* -------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 15px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--nw-teal);
  color: var(--nw-paper);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tr:nth-child(even) {
  background: var(--nw-paper-alt);
}

tr:last-child td {
  border-bottom: none;
}

/* -------------------------------------------------------------------------
   Code / Prompts
   ------------------------------------------------------------------------- */
pre {
  background: #F3E8D8;
  color: var(--nw-ink);
  padding: 20px 24px;
  border: 1px solid #D7C38D;
  border-radius: var(--radius-lg);
  overflow-x: hidden;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  margin: 1.2em 0;
  box-shadow: var(--shadow-md);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

[data-theme="dark"] pre {
  background: #3F382F;
  color: #F1EFE8;
  border-color: #7A684A;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--nw-paper-alt);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--nw-terracotta);
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  white-space: inherit;
  overflow-wrap: inherit;
}

/* -------------------------------------------------------------------------
   Blockquotes
   ------------------------------------------------------------------------- */
blockquote {
  margin: 1.4em 0;
  padding: 20px 24px;
  border: 1px solid var(--border);
  background: var(--nw-paper-alt);
  border-radius: var(--radius-lg);
  font-style: italic;
  font-weight: 300;
}

blockquote p:first-child {
  margin-top: 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   Callouts
   ------------------------------------------------------------------------- */
.callout {
  margin: 1.4em 0;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  background: var(--nw-teal-50);
  border: 1px solid var(--nw-teal-100);
  position: relative;
}

.callout::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 18px;
  width: 8px;
  height: 8px;
  background: var(--nw-teal);
  border-radius: var(--radius-pill);
}

.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

.callout-terra {
  background: #FDF2EE;
  border-color: #F0D5CC;
}
[data-theme="dark"] .callout-terra {
  background: #2A1E1B;
  border-color: #4A302A;
}
.callout-terra::before { background: var(--nw-terracotta); }

.callout-amber {
  background: #FDF6EE;
  border-color: #F0E2CC;
}
[data-theme="dark"] .callout-amber {
  background: #2A261E;
  border-color: #4A3E2A;
}
.callout-amber::before { background: var(--nw-amber); }

/* -------------------------------------------------------------------------
   Horizontal rule
   ------------------------------------------------------------------------- */
hr {
  border: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--nw-amber) 30%, var(--nw-amber) 70%, transparent);
  margin: 2.5em 0;
}

/* -------------------------------------------------------------------------
   Task list / Checkboxes
   ------------------------------------------------------------------------- */
.task-list-item {
  list-style: none;
  padding-left: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.task-list-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--nw-teal);
  margin-top: 4px;
  flex-shrink: 0;
  cursor: pointer;
}

/* -------------------------------------------------------------------------
   Progress tracker
   ------------------------------------------------------------------------- */
.progress-sidebar {
  position: fixed;
  top: 64px;
  left: 0;
  width: 260px;
  height: calc(100vh - 64px);
  background: var(--nw-paper);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 20px rgba(0,0,0,0.06);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.progress-sidebar.open {
  transform: translateX(0);
}

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

.progress-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
}

.progress-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--nw-ink-500);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.progress-close:hover { background: var(--nw-paper-alt); }

.progress-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.progress-section:last-child {
  border-bottom: none;
}

.progress-section h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nw-ink-500);
}

.progress-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}

.progress-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--nw-teal);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.progress-item label {
  cursor: pointer;
  color: var(--nw-ink);
}

.progress-bar-wrap {
  padding: 12px 20px;
  background: var(--nw-paper-alt);
  border-bottom: 1px solid var(--border);
}

.progress-bar-label {
  font-size: 12px;
  color: var(--nw-ink-500);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--nw-teal);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.progress-reset {
  padding: 12px 20px;
  text-align: center;
}

.progress-reset button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--nw-ink-500);
  font-family: var(--font-brand);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}
.progress-reset button:hover {
  border-color: var(--nw-terracotta);
  color: var(--nw-terracotta);
}

.progress-toggle {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--nw-paper);
  color: var(--nw-teal);
  border: 1px solid var(--border);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}
.progress-toggle:hover {
  background: var(--nw-teal-50);
  transform: scale(1.05);
}
.progress-toggle .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--nw-terracotta);
  color: var(--nw-paper);
  font-size: 10px;
  font-weight: 400;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* -------------------------------------------------------------------------
   Annotation UI
   ------------------------------------------------------------------------- */
.annotate-sidebar {
  position: fixed;
  top: 64px;
  right: 0;
  width: 320px;
  height: calc(100vh - 64px);
  background: var(--nw-paper);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.06);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.annotate-sidebar.open {
  transform: translateX(0);
}

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

.annotate-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
}

.annotate-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--nw-ink-500);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.annotate-close:hover { background: var(--nw-paper-alt); }

.annotate-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.annotate-item {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--nw-paper-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}

.annotate-item .quote {
  font-style: italic;
  color: var(--nw-ink-500);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.annotate-item .comment {
  color: var(--nw-ink);
}

.annotate-item .time {
  font-size: 12px;
  color: var(--nw-ink-300);
  margin-top: 6px;
}

.annotate-empty {
  text-align: center;
  color: var(--nw-ink-300);
  font-size: 14px;
  padding: 40px 0;
}

/* Toggle button */
.annotate-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--nw-teal);
  color: var(--nw-paper);
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}
.annotate-toggle:hover {
  background: var(--nw-teal-800);
  transform: scale(1.05);
}
.annotate-toggle .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--nw-terracotta);
  color: var(--nw-paper);
  font-size: 11px;
  font-weight: 400;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Annotation popup */
.annotate-popup {
  position: absolute;
  background: var(--nw-ink);
  color: var(--nw-paper);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 200;
  display: none;
  box-shadow: var(--shadow-lg);
  gap: 8px;
  align-items: center;
}

.annotate-popup button {
  background: var(--nw-teal);
  color: var(--nw-paper);
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.annotate-popup button:hover { background: var(--nw-teal-800); }

.annotate-popup .cancel {
  background: transparent;
  color: var(--nw-ink-300);
  padding: 6px 10px;
}
.annotate-popup .cancel:hover { color: var(--nw-paper); }

/* Highlighted text */
mark.annotated {
  background: rgba(206, 169, 96, 0.35);
  border-radius: 2px;
  padding: 1px 2px;
  cursor: pointer;
}

.anno-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}

.anno-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--nw-ink-300);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.anno-actions button:hover {
  background: var(--nw-paper);
  color: var(--nw-teal);
}

.anno-del:hover {
  color: var(--nw-terracotta) !important;
}

/* -------------------------------------------------------------------------
   Module badge
   ------------------------------------------------------------------------- */
.module-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--nw-teal);
  color: var(--nw-paper);
  margin-bottom: 16px;
}

/* -------------------------------------------------------------------------
   Print styles
   ------------------------------------------------------------------------- */
@media print {
  .topnav,
  .annotate-toggle,
  .annotate-sidebar,
  .progress-toggle,
  .progress-sidebar,
  .theme-toggle,
  .annotate-popup {
    display: none !important;
  }

  body {
    background: #FDFCF9;
    color: #1F1E1E;
    font-size: 12pt;
    line-height: 1.5;
  }

  .page-wrap {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  h1 {
    font-size: 24pt;
    margin-top: 0;
  }

  h2 {
    font-size: 16pt;
    page-break-after: avoid;
    border-bottom: 1pt solid #ccc;
  }

  h3 {
    font-size: 14pt;
    page-break-after: avoid;
  }

  pre {
    background: #f4f4f4;
    color: #1A1A1A;
    box-shadow: none;
    border: 1pt solid #ddd;
    page-break-inside: avoid;
  }

  blockquote {
    background: #F5F3EC;
    border: 1pt solid #D9DACF;
  }

  table {
    box-shadow: none;
    border: 1pt solid #ddd;
  }

  th {
    background: #8CA486;
    color: #FDFCF9;
  }

  a {
    color: #5F735A;
    text-decoration: underline;
  }

  /* Avoid breaking inside important elements */
  .callout,
  blockquote,
  table,
  pre,
  img,
  figure,
  svg {
    page-break-inside: avoid;
  }

  /* Allow page breaks before major sections */
  h1, h2 {
    page-break-before: auto;
  }
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .progress-sidebar { width: 240px; }
}

@media (max-width: 900px) {
  .topnav-inner { padding: 0; }
  .nav-links a { padding: 6px 8px; font-size: 12px; }
  .page-wrap { padding: 32px 20px 64px; }
  .annotate-sidebar { width: 100%; }
  .progress-sidebar { width: 100%; }
}

@media (max-width: 600px) {
  .topnav .brand { font-size: 15px; }
  .nav-links a { padding: 5px 6px; font-size: 11px; }
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
  table { font-size: 13px; }
  th, td { padding: 10px 12px; }
  .progress-toggle { bottom: 88px; right: 20px; width: 44px; height: 44px; }
  .annotate-toggle { width: 52px; height: 52px; }
}
