/* =========================================================
   Ceļš uz studiju nodarbībām — stilu lapa
   Monohromatiska krāsu palete · Roboto Mono · gaišs/tumšs režīms
   ========================================================= */

/* -------- Tēmas: krāsu mainīgie -------- */
:root,
[data-theme="light"] {
  --bg:          #E1ECEE;
  --bg-soft:     #A6C9CD;
  --panel:       #A6C9CD;
  --accent-1:    #5A8B90;
  --accent-2:    #2F5D62;
  --text:        #070606;
  --text-soft:   #2b3a3c;
  --line:        rgba(7, 6, 6, 0.12);
  --shadow:      0 8px 24px rgba(47, 93, 98, 0.18);
  --overlay:     rgba(225, 236, 238, 0.92);
  --side-nav-bg: rgba(7, 6, 6, 0.55);
  --side-nav-text: #E1ECEE;
}

[data-theme="dark"] {
  --bg:          #0F1F21;
  --bg-soft:     #1F3D40;
  --panel:       #1F3D40;
  --accent-1:    #4F8488;
  --accent-2:    #7FB5B9;
  --text:        #E4E4E4;
  --text-soft:   #a6c9cd;
  --line:        rgba(228, 228, 228, 0.14);
  --shadow:      0 8px 28px rgba(0, 0, 0, 0.45);
  --overlay:     rgba(15, 31, 33, 0.92);
  --side-nav-bg: rgba(228, 228, 228, 0.12);
  --side-nav-text: #E4E4E4;
}

/* -------- Reset / pamati -------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Roboto Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0 0 1em 0; }

a {
  color: var(--accent-2);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { color: var(--accent-1); }
a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 2px;
}

code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

em { font-style: italic; color: var(--text-soft); }

/* -------- Pielāgota ritjosla -------- */
/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-2) var(--bg-soft);
}

/* WebKit / Chromium / Safari */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: var(--bg-soft);
}
::-webkit-scrollbar-thumb {
  background: var(--accent-1);
  border: 3px solid var(--bg-soft);
  border-radius: 8px;
  transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-2);
}
::-webkit-scrollbar-corner {
  background: var(--bg-soft);
}

/* =========================================================
   TOP BAR (sticky)
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1fr;
  gap: 24px;
  align-items: start;
  padding: 18px 32px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar__title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar__pretitle {
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.topbar__h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ---- Top navigation (desktop) ---- */
.topnav {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-right: 0;
  padding-top: 24px;
}

.topnav__list {
  display: flex;
  gap: 10px;
  list-style: none;
  margin: 0 0 0 -50px;
  padding: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.topnav__btn {
  display: inline-block;
  padding: 12px 20px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}
.topnav__btn:hover { transform: translateY(-1px); }
.topnav__btn:hover {
  background: var(--accent-1);
  color: var(--bg);
}
.topnav__btn.is-active {
  background: var(--accent-2);
  color: var(--bg);
  border-color: var(--accent-2);
}

/* ---- Theme toggle — large, anchored to top-right of viewport ---- */
.theme-toggle {
  width: clamp(40px, 5vw, 80px);
  height: clamp(40px, 5vw, 80px);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  margin-left: 12px;
  margin-top: -8px; /* lift slightly above button row */
}
.theme-toggle:hover { background: var(--accent-1); color: var(--bg); transform: rotate(15deg); }

.theme-toggle__icon { width: clamp(18px, 2.2vw, 34px); height: clamp(18px, 2.2vw, 34px); }
[data-theme="light"] .theme-toggle__icon--sun { display: none; }
[data-theme="light"] .theme-toggle__icon--moon { display: block; }
[data-theme="dark"]  .theme-toggle__icon--sun  { display: block; }
[data-theme="dark"]  .theme-toggle__icon--moon { display: none; }

/* ---- Hamburger (mobile only) ---- */
.hamburger {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile nav drawer ---- */
.mobile-nav {
  position: fixed;
  top: var(--mobile-nav-top, 92px);
  right: 16px;
  z-index: 99;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 200px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - var(--mobile-nav-top, 92px) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mobile-nav[hidden] { display: none; }
.mobile-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-nav a {
  display: block;
  padding: 10px 14px;
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.mobile-nav a:hover,
.mobile-nav a.is-active {
  background: var(--accent-2);
  color: var(--bg);
}

/* =========================================================
   MAIN LAYOUT — sticky photo + scrollable content
   ========================================================= */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 40%) 1fr;
  column-gap: 32px;
  align-items: start;
  max-width: 1700px;
  margin: 0 auto;
}

/* ---- Left: sticky photo panel ---- */
.photo-panel {
  position: sticky;
  top: calc(var(--topbar-h, 100px) + 8px);
  height: calc(100vh - var(--topbar-h, 100px) - 16px);
  padding: 24px 0 24px 24px;
  display: flex;
  flex-direction: column;
}

.photo-panel__inner {
  background: var(--panel);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.photo-panel__head {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.photo-panel__day {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 500;
}
[data-theme="dark"] .photo-panel__day { color: var(--accent-2); }

.photo-panel__title {
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.2;
  color: var(--text);
  font-weight: 700;
}

/* photo stage — slides area on top, caption row beneath */
.photo-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* Slides container — fills available space; slides stack inside */
.photo-stage__slides {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.slide.is-active {
  opacity: 1;
  pointer-events: auto;
}

.slide .illu {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.slide .illu svg,
.slide .illu img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

/* Caption now lives outside the slide stack — no opacity-stacking-context bugs */
.photo-caption {
  flex-shrink: 0;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  background: var(--overlay);
  border-top: 1px solid var(--line);
}

/* Side navigation overlay — only over the slides area, never over the caption */
.side-nav {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: var(--side-nav-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 20px 16px;
  min-width: 140px;
  display: flex;
  align-items: center;
}
.side-nav ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: chapter;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.side-nav li {
  counter-increment: chapter;
}
.side-nav a {
  display: block;
  color: var(--side-nav-text);
  font-size: 12px;
  padding: 4px 0;
  border-left: 2px solid transparent;
  padding-left: 8px;
  transition: border-color 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
  letter-spacing: 0.02em;
}
.side-nav a::before {
  content: counter(chapter, decimal-leading-zero) " · ";
  opacity: 0.6;
}
.side-nav a:hover {
  color: var(--bg);
  padding-left: 12px;
}
.side-nav a.is-active {
  border-left-color: var(--side-nav-text);
  font-weight: 700;
  padding-left: 12px;
}

.photo-panel__meta {
  margin: 16px 0 0;
  font-size: 11px;
  color: var(--text-soft);
  text-align: center;
}

/* ---- Right: scrollable content ---- */
.content {
  padding: 32px 5vw 64px 32px;
  max-width: none;
  width: 100%;
}

/* =========================================================
   CHAPTERS
   ========================================================= */
.chapter {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--topbar-h, 100px) + 24px);
}
.chapter:last-of-type { border-bottom: none; }

.chapter--intro {
  padding-top: 24px;
}

.chapter__num {
  font-size: 14px;
  color: var(--accent-1);
  letter-spacing: 0.15em;
  font-weight: 500;
  margin-bottom: 8px;
}

.chapter__title {
  font-size: clamp(36px, 5vw, 72px);
  line-height: 1.05;
  margin-bottom: 24px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chapter__lead {
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.45;
  color: var(--text);
  font-weight: 400;
  margin-bottom: 32px;
  padding-left: 16px;
  border-left: 3px solid var(--accent-2);
}

.chapter p {
  font-size: clamp(13px, 1.1vw, 17px);
  line-height: 1.7;
  color: var(--text);
  max-width: none;
  margin-bottom: 1.2em;
}

.subsection {
  margin-top: 40px;
  padding: 24px;
  background: var(--bg-soft);
  border-radius: 6px;
  border-left: 4px solid var(--accent-2);
}
.subsection__title {
  font-size: clamp(18px, 1.8vw, 24px);
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 700;
}
.subsection p:last-child { margin-bottom: 0; }

/* Mobile inline figures — hidden on desktop because the sticky panel handles imagery */
.mobile-figure { display: none; }

/* =========================================================
   FOOTER
   ========================================================= */
.footer {
  margin-top: 64px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
}
.footer p { margin: 0 0 8px 0; }
.footer__small { font-size: 12px; opacity: 0.8; }

/* =========================================================
   RESPONSIVE — tablet (<=1100px)
   ========================================================= */
@media (max-width: 1100px) {
  .topbar { padding: 16px 24px; }
  .photo-panel { padding: 24px 16px 24px 24px; }
  .content { padding: 24px 24px 48px 16px; }
  .layout { grid-template-columns: minmax(320px, 45%) 1fr; }
  .topnav__btn { padding: 6px 10px; font-size: 12px; }
}

/* =========================================================
   RESPONSIVE — mobile (<=800px)
   Single column. Photo panel hidden, inline figures shown.
   Hamburger appears, desktop nav list hidden.
   ========================================================= */
@media (max-width: 800px) {
  body { font-size: 14px; }

  .topbar {
    grid-template-columns: 1fr auto;
    padding: 14px 16px;
    align-items: center;
    gap: 12px;
  }
  .topbar__h1 { font-size: 28px; }
  .topbar__pretitle { font-size: 10px; }

  .topnav { gap: 8px; padding-top: 0; }
  .topnav__list { display: none; }
  .hamburger { display: flex; }

  /* Match theme toggle to hamburger size on mobile */
  .theme-toggle {
    width: 44px;
    height: 44px;
    margin-top: 0;
    margin-left: 0;
    box-shadow: none;
  }
  .theme-toggle__icon { width: 18px; height: 18px; }

  .layout {
    grid-template-columns: 1fr;
  }

  .photo-panel {
    display: none;
  }

  .content {
    padding: 16px 16px 48px;
    max-width: 100%;
  }

  .chapter {
    padding: 32px 0 16px;
    scroll-margin-top: 90px;
  }

  .chapter__title {
    font-size: 48px;
    margin-bottom: 16px;
  }

  .chapter__lead {
    font-size: 18px;
    margin-bottom: 20px;
    padding-left: 12px;
  }

  .chapter p {
    font-size: 14px;
    line-height: 1.65;
  }

  /* Mobile inline figures replace the sticky panel */
  .mobile-figure {
    display: block;
    margin: 24px 0;
  }
  .mobile-figure .illu {
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
    aspect-ratio: 4 / 3;
  }
  .mobile-figure .illu svg,
  .mobile-figure .illu img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
  }
  .mobile-figure figcaption {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.4;
    text-align: center;
  }

  .subsection {
    padding: 16px;
    margin-top: 24px;
  }
  .subsection__title { font-size: 16px; }
}

/* =========================================================
   RESPONSIVE — very small phones (<=420px)
   ========================================================= */
@media (max-width: 420px) {
  .topbar__h1 { font-size: 22px; }
  .chapter__title { font-size: 36px; }
  .chapter__lead { font-size: 16px; }
  .theme-toggle { width: 36px; height: 36px; }
  .hamburger { width: 40px; height: 40px; }
}

/* =========================================================
   PRINT
   ========================================================= */
@media print {
  .topbar, .photo-panel, .mobile-nav, .hamburger, .theme-toggle, .side-nav {
    display: none !important;
  }
  .layout { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: 100%; }
  .mobile-figure { display: block; }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
