/* ══════════════════════════════════════════════
   discipline.css — Hybrid Premium
   Layout: header sticky + sidebar + main content
   ══════════════════════════════════════════════ */

/* ── Layout base ── */
body {
  display: flex;
  flex-direction: column;
  font-family: var(--font-outfit);
}
.layout { display: flex; flex: 1; min-height: 0; }

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(7, 7, 16, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
}
.menu-btn:hover { background: rgba(255,255,255,.06); }
.menu-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--muted);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color .2s;
  flex-shrink: 0;
}
.back::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238b949e' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 12H5M12 5l-7 7 7 7'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}
.back:hover { color: var(--text); }

.back + h1::before {
  content: "/";
  color: var(--border);
  margin-right: .75rem;
  font-weight: 300;
}

header h1 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

header .search-btn { margin-left: auto; }

.tag {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: rgba(63,185,80,.1);
  color: var(--accent2);
  border: 1px solid rgba(63,185,80,.2);
  padding: .2rem .55rem;
  border-radius: 20px;
  margin-left: .5rem;
  flex-shrink: 0;
}

/* ── Sidebar ── */
aside {
  width: 256px;
  min-width: 256px;
  background: rgba(10, 10, 20, 0.6);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 56px;
  height: calc(100dvh - 56px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem 0 2rem;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
aside::-webkit-scrollbar { width: 4px; }
aside::-webkit-scrollbar-track { background: transparent; }
aside::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

.sidebar-group { margin-bottom: 1.5rem; }

.sidebar-label {
  display: block;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(139, 148, 158, 0.5);
  padding: .2rem 1.25rem .5rem;
}

aside a {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .4rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 400;
  transition: background .12s, color .12s, border-color .12s;
  border-left: 2px solid transparent;
  line-height: 1.4;
}
aside a:hover {
  background: rgba(255,255,255,.03);
  color: var(--text);
}
aside a.active {
  background: rgba(88,166,255,.06);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

aside a .num {
  font-size: .65rem;
  font-weight: 600;
  opacity: .4;
  min-width: 28px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
}
aside a.active .num { opacity: .7; }

/* ── Main content ── */
main {
  flex: 1;
  padding: 2.5rem 3rem 4rem;
  max-width: 820px;
  min-width: 0;
}

section { display: none; }
section.active { display: block; }

/* ── WIP / centred main ── */
main.wip {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem;
  min-height: calc(100dvh - 56px);
}

/* ── Typography ── */
/* ── Heading scroll offset (compensa header sticky 56px) ── */
h2, h3, h4, h5, h6 {
  scroll-margin-top: 72px;
}

/* ── Highlight quando navegado via anchor ── */
:target {
  animation: anchorPulse .9s cubic-bezier(.16,1,.3,1) both;
}
@keyframes anchorPulse {
  0%   { background: rgba(88,166,255,.14); border-radius: 6px; }
  100% { background: transparent; }
}

section > h2 {
  font-family: var(--font-outfit);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.6px;
  line-height: 1.15;
  margin-bottom: .4rem;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  font-size: .92rem;
  margin-bottom: 2rem;
  line-height: 1.7;
}

h3 {
  font-family: var(--font-outfit);
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent);
  margin: 2.25rem 0 .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  letter-spacing: -.2px;
}
h3::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

h4 {
  font-family: var(--font-outfit);
  font-size: .82rem;
  font-weight: 700;
  color: var(--accent4);
  margin: 1.5rem 0 .5rem;
  letter-spacing: -.1px;
}

p {
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: .75rem;
}

ul, ol { padding-left: 1.4rem; margin-bottom: .75rem; }
li { font-size: .86rem; color: var(--muted); line-height: 1.75; }
li strong, strong { color: var(--text); }

/* ── Internal cards grid ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin: 1rem 0;
}
.card {
  background: rgba(22, 22, 38, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  transition: border-color .2s;
}
.card:hover { border-color: rgba(88,166,255,.25); }
.card h4 { color: var(--text); margin: 0 0 .4rem; font-size: .82rem; }
.card p { font-size: .78rem; margin: 0; }

/* ── Code ── */
pre {
  background: rgba(5, 5, 15, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: .75rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
code {
  font-family: var(--font-jetbrains-mono);
  font-size: .8rem;
  color: #e6edf3;
  line-height: 1.65;
}
p code, li code {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 5px;
  padding: .1rem .4rem;
  font-size: .78rem;
  color: var(--text);
}

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .83rem; border-radius: var(--radius-sm); overflow: hidden; }
th {
  background: rgba(22, 22, 38, 0.8);
  color: var(--text);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td {
  padding: .6rem .9rem;
  color: var(--muted);
  border-bottom: 1px solid rgba(48,54,61,.4);
  line-height: 1.5;
}
td:first-child { color: var(--text); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.015); }

/* ── Callouts ── */
.callout {
  background: rgba(88,166,255,.05);
  border: 1px solid rgba(88,166,255,.15);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  backdrop-filter: blur(4px);
}
.callout.green   { background: rgba(63,185,80,.05);   border-color: rgba(63,185,80,.15); }
.callout.orange  { background: rgba(247,129,102,.05); border-color: rgba(247,129,102,.15); }
.callout.warning { background: rgba(247,129,102,.05); border-color: rgba(247,129,102,.15); }
.callout.tip     { background: rgba(210,168,255,.05); border-color: rgba(210,168,255,.15); }

.callout strong { display: block; margin-bottom: .35rem; color: var(--text); font-size: .88rem; }
.callout p { margin: 0; font-size: .83rem; }
.callout ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.callout ul li { font-size: .8rem; }

/* ── Diagram ASCII ── */
.diagram {
  background: rgba(5, 5, 15, 0.6);
  border: 1px dashed rgba(48,54,61,.6);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin: 1rem 0;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  font-family: monospace;
  white-space: pre;
  line-height: 1.6;
  overflow-x: auto;
}

/* ── Section nav (prev/next) ── */
.section-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.section-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 500;
  padding: .5rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .2s, color .2s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.section-nav a:hover { border-color: var(--accent); color: var(--accent); }
.section-nav a.next::after  { content: "→"; }
.section-nav a.prev::before { content: "←"; }

/* ── Ref text ── */
.ref { font-size: .73rem !important; color: rgba(110,118,129,.6) !important; margin-top: 1.5rem !important; }

/* ── Slide gallery ── */
.slide-gallery { margin: 1.5rem 0; }

.slide-gallery .gallery-label {
  display: block;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent4);
  opacity: .7;
  margin-bottom: .75rem;
}

.slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
}

.slide-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  background: rgba(10, 10, 20, 0.6);
}
.slide-item:hover {
  border-color: rgba(210,168,255,.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
}
.slide-item img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }

/* Portrait (vertical) images */
.slide-item--portrait { grid-column: span 1; max-width: 320px; justify-self: center; }
.slide-item--portrait img { aspect-ratio: 9/16; object-fit: contain; background: rgba(5,5,15,.6); }
html[data-theme="light"] .slide-item--portrait img { background: rgba(230,236,248,.5); }
.slide-item figcaption {
  font-size: .7rem;
  color: var(--muted);
  padding: .4rem .65rem;
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, .92);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.lightbox.open { display: flex; }
.lightbox-img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 32px 80px rgba(0,0,0,.6);
}
.lightbox-close {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color .2s, background .2s;
}
.lightbox-close:hover { color: var(--text); background: rgba(255,255,255,.1); }
.lightbox-prev, .lightbox-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, background .2s;
}
.lightbox-prev:hover, .lightbox-next:hover { color: var(--text); background: rgba(255,255,255,.1); }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-caption {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(8px);
  padding: .4rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ── Nav overlay (mobile backdrop) ── */
#nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 150;
  backdrop-filter: blur(2px);
}
#nav-overlay.open { display: block; }

/* ── WIP page styles ── */
.wip-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.75rem;
}
.wip-icon svg { opacity: .9; }

.wip-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -.6px;
  margin-bottom: .75rem;
  color: var(--text);
}

.wip-desc {
  color: var(--muted);
  font-size: .95rem;
  max-width: 460px;
  line-height: 1.75;
  margin: 0 auto 2rem;
}

.wip-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .45rem;
  margin-bottom: 2.5rem;
}
.wip-chip {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 500;
  padding: .3rem .75rem;
  border-radius: 20px;
}

.wip-progress {
  width: 240px;
  height: 4px;
  background: rgba(255,255,255,.05);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto .75rem;
}
.wip-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  transition: width .6s ease;
}
.wip-progress-label {
  font-size: .7rem;
  color: var(--muted);
  opacity: .6;
  margin-bottom: 2.5rem;
}

.wip-back {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1.4rem;
  background: rgba(88,166,255,.08);
  border: 1px solid rgba(88,166,255,.2);
  border-radius: var(--radius-sm);
  color: var(--accent);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 600;
  transition: background .2s, border-color .2s;
}
.wip-back:hover { background: rgba(88,166,255,.14); border-color: rgba(88,166,255,.4); }

/* ── Footer (discipline pages) ── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: .78rem;
  flex-shrink: 0;
}
footer a { color: var(--accent); text-decoration: none; font-weight: 500; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .menu-btn { display: flex; }

  aside {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-110%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    border-right-color: rgba(255,255,255,.1);
    padding-top: 1rem;
  }
  aside.open { transform: translateX(0); }

  main { padding: 1.5rem 1.25rem 3rem; max-width: 100%; }
  header { padding: 0 1rem; }
  header h1 { font-size: .85rem; }

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

@media (max-width: 480px) {
  .slides-grid { grid-template-columns: 1fr; }
  .section-nav { flex-direction: column; }
  .section-nav a { justify-content: center; }
}

/* ═══════════════════════════════════════════════════════
   LIGHT MODE — discipline layout overrides
   ═══════════════════════════════════════════════════════ */

html[data-theme="light"] header {
  background: rgba(240,244,255,.92);
}
html[data-theme="light"] .menu-btn:hover { background: rgba(0,14,77,.06); }
html[data-theme="light"] .menu-btn span { background: var(--muted); }

html[data-theme="light"] aside {
  background: rgba(248,250,255,.9);
  border-right-color: var(--border);
  scrollbar-color: rgba(0,14,77,.1) transparent;
}
html[data-theme="light"] aside::-webkit-scrollbar-thumb { background: rgba(0,14,77,.1); }
html[data-theme="light"] aside a:hover { background: rgba(0,14,77,.04); }
html[data-theme="light"] aside a.active { background: rgba(9,105,218,.07); }

html[data-theme="light"] .card {
  background: rgba(255,255,255,.85);
}
html[data-theme="light"] .card:hover { border-color: rgba(9,105,218,.3); }

/* Código mantém fundo escuro intencionalmente (legibilidade) */
html[data-theme="light"] pre {
  background: #161b22;
  border-color: rgba(0,14,77,.12);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
html[data-theme="light"] p code,
html[data-theme="light"] li code,
html[data-theme="light"] td code,
html[data-theme="light"] th code {
  background: rgba(175,184,193,.2);
  border-color: rgba(0,14,77,.1);
  color: var(--text);
}
html[data-theme="light"] h2 code,
html[data-theme="light"] h3 code,
html[data-theme="light"] h4 code {
  color: inherit;
}

html[data-theme="light"] th { background: rgba(230,236,248,.9); }
html[data-theme="light"] td { border-bottom-color: rgba(0,14,77,.07); color: var(--text); }
html[data-theme="light"] td:first-child { color: var(--text); }
html[data-theme="light"] tr:hover td { background: rgba(0,14,77,.02); }

html[data-theme="light"] .diagram {
  background: rgba(240,244,255,.6);
  border-color: rgba(0,14,77,.15);
}

html[data-theme="light"] .slide-item { background: #ffffff; }
html[data-theme="light"] .slide-item:hover { box-shadow: 0 8px 20px rgba(0,0,0,.1); }
html[data-theme="light"] .slide-item figcaption { border-top-color: var(--border); }

html[data-theme="light"] footer { border-top-color: var(--border); }

/* Lightbox permanece escuro independente do tema */
html[data-theme="light"] .lightbox-close,
html[data-theme="light"] .lightbox-prev,
html[data-theme="light"] .lightbox-next {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.18);
  color: rgba(255,255,255,.8);
}
html[data-theme="light"] .lightbox-caption {
  background: rgba(0,0,0,.7);
  border-color: rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
}

/* Back arrow icon — versão light */
html[data-theme="light"] .back::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2357606a' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 12H5M12 5l-7 7 7 7'/%3E%3C/svg%3E");
}

html[data-theme="light"] #nav-overlay.open { background: rgba(0,0,0,.4); }

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) header { background: rgba(240,244,255,.92); }
  html:not([data-theme="dark"]) aside { background: rgba(248,250,255,.9); scrollbar-color: rgba(0,14,77,.1) transparent; }
  html:not([data-theme="dark"]) .card { background: rgba(255,255,255,.85); }
  html:not([data-theme="dark"]) pre { background: #161b22; border-color: rgba(0,14,77,.12); }
  html:not([data-theme="dark"]) p code,
  html:not([data-theme="dark"]) li code,
  html:not([data-theme="dark"]) td code,
  html:not([data-theme="dark"]) th code { background: rgba(175,184,193,.2); border-color: rgba(0,14,77,.1); color: var(--text); }
  html:not([data-theme="dark"]) h2 code,
  html:not([data-theme="dark"]) h3 code,
  html:not([data-theme="dark"]) h4 code { color: inherit; }
  html:not([data-theme="dark"]) th { background: rgba(230,236,248,.9); }
  html:not([data-theme="dark"]) td { border-bottom-color: rgba(0,14,77,.07); color: var(--text); }
  html:not([data-theme="dark"]) td:first-child { color: var(--text); }
  html:not([data-theme="dark"]) .slide-item { background: #ffffff; }
  html:not([data-theme="dark"]) .diagram { background: rgba(240,244,255,.6); border-color: rgba(0,14,77,.15); }
  html:not([data-theme="dark"]) .back::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2357606a' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 12H5M12 5l-7 7 7 7'/%3E%3C/svg%3E");
  }
}
