@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,440;0,9..144,600;0,9..144,700;1,9..144,500&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #fbeaf0;
  --bg-elevated: #ffffff;
  --ink: #3a2c25;
  --ink-dim: #7a6a5c;
  --ink-faint: #a49385;
  --line: #ecdfd6;
  --line-strong: #d8c3b5;
  --accent: #8a5a3b;
  --accent-dark: #5c3b26;
  --accent-ink: #fff8f4;
  --accent-soft: #f7d9e3;
  --done: #8a5a3b;
  --done-soft: #f7d9e3;
  --shadow: 0 1px 2px rgba(58,44,37,0.06), 0 8px 24px -12px rgba(58,44,37,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; color: var(--ink); }
code, .mono, pre { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ---- login screen ---- */

#screen-login {
  /* Swap this path for your own image — drop the file in
     frontend/assets/ and change the filename below to match. */
  background-image: url("assets/wallpaper.jpg");
  background-size: cover;
  background-position: center;
}

.login-card {
  background: var(--bg-elevated);
  border: 2px solid var(--accent);
  padding: 34px 36px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  margin-bottom: 25vh; /* nudges it above dead-center */
  margin-right: 2vh;
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 20px;
}

.auth-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.toggle-btn {
  flex: 1;
  padding: 9px 0;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 9px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
}
.toggle-btn.active { background: var(--accent); color: var(--accent-ink); }

#auth-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-dim);
  margin-bottom: 14px;
}
#auth-form label[hidden] {
  display: none;
}

#auth-form input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1.5px solid var(--accent);
  border-radius: 9px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--accent-soft);
}
#auth-form input:focus {
  outline: none;
  border-color: var(--accent-dark);
  background: var(--bg-elevated);
}

#auth-form button[type="submit"] {
  width: 100%;
  padding: 11px 0;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 9px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 8px;
}
#auth-form button[type="submit"]:disabled { opacity: 0.6; cursor: default; }

.error-text {
  color: #a03a2c;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

/* ---- tracker screen ---- */

#screen-tracker { align-items: flex-start; }

/* Pinned to the viewport (not the page), so they stay put while .wrap
   scrolls underneath/between them. A middle-ground width — wider than
   the original 190px sliver, nowhere near the full-height version — and
   object-fit:cover so it always fills the box edge to edge (no letterbox
   gaps showing the pink page background through). */
.side-bar {
  display: none;
  position: fixed;
  top: 0;
  bottom: 0;
  width: 320px;
}
.side-bar--left { left: 0; }
.side-bar--right { right: 0; }
.side-bar img {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: cover;
}
@media (min-width: 1600px) {
  .side-bar { display: block; }
}

.wrap {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 44px 24px 100px;
}

.tracker-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.tracker-header h1 { font-size: 2rem; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 14px; }

.me-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 100px;
}

.logout-btn {
  padding: 7px 15px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 9px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
}

.stats { display: flex; gap: 20px; margin-top: 24px; flex-wrap: wrap; }
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: var(--shadow);
  min-width: 120px;
}
.stat .n {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
}
.stat .l {
  font-size: 0.72rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ---- breadcrumb nav ---- */

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 24px 0 18px;
}
.crumbs button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0;
}
.crumbs .current { color: var(--ink-dim); }

.view-title { font-size: 1.6rem; margin-bottom: 4px; }
.view-sub { color: var(--ink-dim); font-size: 0.9rem; margin-bottom: 20px; }

/* ---- card grid (topics view, sections view) ---- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.nav-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  /* Wider than tall — a flex column so the stacked title/sub/progress
     center nicely inside the shorter box instead of the card growing
     tall to fit them. */
  aspect-ratio: 2.4 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  text-decoration: none;
  color: inherit;
}
.nav-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(58,44,37,0.08), 0 12px 28px -12px rgba(58,44,37,0.26);
}
.nav-card .card-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.15rem;
  margin-bottom: 6px;
}
.nav-card .card-sub {
  color: var(--ink-dim);
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.nav-card .card-progress {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent-dark);
  background: var(--accent-soft);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
}

/* Same card shell, different left-accent per nav level — a quick visual
   cue for "how deep am I" without needing separate layouts. */
.nav-card--topic { border-left-color: var(--accent-dark); }
.nav-card--category { border-left-color: #a06a26; }
.nav-card--section { border-left-color: var(--accent); }

/* Personalized watermark on every card — whoever's logged in sees their
   own "kiss" sticker faded into the empty half of each card, always on
   the opposite side from the text so nothing collides: Dudu gets
   dudukiss on the right (text stays left), Bubu gets bubukiss on the
   left (text stays right). Class is set on <body> in app.js from
   currentUser.persona right after login. */
.nav-card { position: relative; overflow: hidden; }
.nav-card .card-title,
.nav-card .card-sub,
.nav-card .card-progress {
  position: relative;
  z-index: 1;
}
.nav-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 46%;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  opacity: 0.1;
  pointer-events: none;
  z-index: 0;
}

body.persona-dudu .nav-card { padding-right: 48%; }
body.persona-dudu .nav-card::before {
  right: 0;
  background-image: url("assets/dudukiss.png");
}

body.persona-bubu .nav-card { padding-left: 48%; }
body.persona-bubu .nav-card::before {
  left: 0;
  background-image: url("assets/bubukiss.png");
}

.empty-state {
  color: var(--ink-dim);
  font-size: 0.92rem;
  background: var(--bg-elevated);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 20px 22px;
}

/* ---- question list (collapsed by default) ---- */

.section-blurb {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: 0 0 22px;
  max-width: 64ch;
}
.section-blurb strong { color: var(--ink); }

.question-list {
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.question-row {
  border-bottom: 1px solid var(--line);
}
.question-row:last-child { border-bottom: none; }
.question-row.expanded { background: var(--accent-soft); background: #fef6f8; }

.row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
}
.row-head:hover { background: #fef6f8; }

.chevron {
  color: var(--ink-faint);
  font-size: 0.75rem;
  width: 12px;
  flex-shrink: 0;
}

.q-title { font-size: 0.92rem; flex: 1; min-width: 120px; }

.chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: capitalize;
  text-decoration: none;
  flex-shrink: 0;
}
.diff-easy    { background: #dff2e2; color: #2b6a4f; }
.diff-medium  { background: #fbe9c9; color: #9a6a1a; }
.diff-hard    { background: #f8d9d5; color: #a03a2c; }
.diff-concept { background: #e2e4f5; color: #4b4f9a; }
.chip.link { background: var(--accent-soft); color: var(--accent-dark); }

.row-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 12px 38px;
  flex-wrap: wrap;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-dim);
  cursor: pointer;
}
.check input[type="checkbox"] {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  margin: 0;
  cursor: pointer;
  position: relative;
  background: var(--bg-elevated);
}
.check input[type="checkbox"]:checked {
  background: var(--done);
  border-color: var(--done);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute; left: 5px; top: 1px;
  width: 4px; height: 9px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}
.check input[type="checkbox"]:disabled { opacity: 0.5; cursor: default; }

.friend-chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.row-details[hidden] { display: none; }
.row-details {
  padding: 6px 16px 22px 38px;
}

.q-note-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.q-note {
  color: var(--ink-dim);
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 16px;
  max-width: 68ch;
}

.view-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #1e1e2e;
  color: #cdd6f4;
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.view-code-btn:hover { background: #29283e; }

/* ---- code dialog: deliberately a totally different palette from the
   rest of the app, so code reads as "a different surface" ---- */

.code-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(720px, 92vw);
  max-height: 82vh;
  background: #1e1e2e;
  color: #cdd6f4;
  box-shadow: 0 20px 60px -12px rgba(0,0,0,0.5);
  /* Explicit fixed centering rather than relying on the browser's
     built-in <dialog> centering — that default stops truly centering
     once content is tall enough to hit max-height, which read as the
     dialog being stuck to one side. This keeps it centered always. */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  /* flex column + min-height:0 on the scrolling child below is what
     actually fixes the "cropped" bug — without min-height:0, a flex
     child ignores max-height and overflows instead of scrolling. */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* An author rule always beats the browser's own UA stylesheet, even one
   as basic as "a <dialog> without [open] is display:none" — so without
   this, the unconditional display:flex above makes the dialog visible
   (as a squashed bar) on every screen, not just while showModal() has it
   open. Re-asserting the hidden case explicitly fixes that. */
.code-dialog:not([open]) {
  display: none;
}
.code-dialog::backdrop {
  background: rgba(20, 14, 20, 0.6);
  backdrop-filter: blur(2px);
}

.code-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #33324a;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.dialog-close {
  background: none;
  border: none;
  color: #9a97b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.dialog-close:hover { background: #2c2b40; color: #cdd6f4; }

.code-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 20px 0;
  flex-shrink: 0;
}
.code-tab {
  background: #181722;
  color: #9a97b8;
  border: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 18px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.code-tab.active { background: #181722; color: #cdd6f4; }
.code-tab:not(.active) { opacity: 0.55; }
.code-tab.lang-java.active { box-shadow: inset 0 -2px 0 #f4a261; }
.code-tab.lang-python.active { box-shadow: inset 0 -2px 0 #7dc4e4; }
.code-tabs[hidden] { display: none; }

.code-dialog-body {
  padding: 16px 20px 22px;
  overflow-y: auto;
  min-height: 0;   /* the actual fix — lets this child scroll instead of overflowing */
  flex: 1 1 auto;
}

.code-pane[hidden] { display: none; }

.code-block {
  background: #181722;
  border-radius: 10px;
  overflow: hidden;
}
.code-block .code-lang {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 14px;
  color: #1e1e2e;
}
.code-block.lang-java .code-lang { background: #f4a261; }
.code-block.lang-python .code-lang { background: #7dc4e4; }
.code-block pre {
  padding: 14px;
  overflow-x: auto;
  color: #cdd6f4;
  font-size: 0.82rem;
  line-height: 1.7;
  white-space: pre;
}
.code-block pre .kw { color: #f4a9d0; font-weight: 600; }
.code-block pre {
  padding: 14px;
  overflow-x: auto;
  color: #cdd6f4;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre;
}
