/* ==========================================================
   Engram — minimal, warm, editorial (inspired by antigravity.google)
   ========================================================== */

:root {
  --radius: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino", Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, monospace;
}

/* Light Theme (Schwarz Digits aligned) */
:root, html[data-theme="light"] {
  --bg: #f4f7f9; /* Soft light gray-blue */
  --surface: #ffffff;
  --ink: #0a1e2d; /* Digits Navy Blue */
  --ink-soft: #556877; /* Soft navy-gray */
  --hairline: #d5e0e8; /* Soft blue-gray divider */
  --accent: #008b94; /* Space Mint adjusted for readability */
  --accent-ink: #ffffff;
  --danger: #c2422f;
  
  --shadow-color: rgba(10, 30, 45, 0.04);
  --shadow-hover: rgba(10, 30, 45, 0.08);
  --modal-backdrop: rgba(10, 30, 45, 0.3);
}

/* Dark Theme (Schwarz Digits colors) */
html[data-theme="dark"] {
  --bg: #0a1e2d; /* Digits Navy Blue */
  --surface: #142b3e; /* Lighter navy blue for surfaces */
  --ink: #ffffff; /* White */
  --ink-soft: #a0b2c1; /* Soft blue-gray text */
  --hairline: #1e384d; /* Dark navy divider */
  --accent: #00c3cd; /* Digits Space Mint */
  --accent-ink: #0a1e2d; /* Navy text on mint background */
  --danger: #ff6b57;
  
  --shadow-color: rgba(0, 0, 0, 0.25);
  --shadow-hover: rgba(0, 0, 0, 0.4);
  --modal-backdrop: rgba(0, 0, 0, 0.6);
}


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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--hairline);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.brand-mark {
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 900;
  -webkit-text-stroke: 1px var(--accent);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.role-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  background: var(--surface);
}

.icon-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.18s ease;
}
.icon-round:hover { color: var(--ink); border-color: var(--accent); }

/* ---------- layout ---------- */

#app { flex: 1; width: 100%; }

.view { padding: 4rem 2rem; }

.narrow { max-width: 26rem; margin: 0 auto; }
.wide   { max-width: 58rem; margin: 0 auto; }

.footer {
  padding: 2rem 2rem;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.footer svg {
  height: 22px;
  width: auto;
  opacity: 0.85;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.footer svg:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.footer .logo-light {
  display: block;
}

.footer .logo-dark {
  display: none;
}

html[data-theme="dark"] .footer .logo-light {
  display: none;
}

html[data-theme="dark"] .footer .logo-dark {
  display: block;
}

/* ---------- typography ---------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.display {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.display em { font-style: italic; color: var(--accent); }

.title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.15;
}

.lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin-top: 1.25rem;
  max-width: 34rem;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1.3rem;
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  background: none;
  color: var(--ink);
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); }

.btn-ghost {
  border-color: var(--hairline);
  background: var(--surface);
  color: var(--ink-soft);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--accent); }

.btn-danger-ghost {
  border-color: var(--hairline);
  background: var(--surface);
  color: var(--danger);
}
.btn-danger-ghost:hover { border-color: var(--danger); }

.back-link { margin-bottom: 2.5rem; }

/* ---------- deck card cta ---------- */

.role-card-cta {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  color: var(--accent);
}

/* ---------- forms ---------- */

.input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  resize: vertical;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.input:focus { outline: none; border-color: var(--accent); }

.input-lg { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }

.pin-form { margin-top: 2rem; display: flex; flex-direction: column; gap: 1rem; }

.field { display: flex; flex-direction: column; gap: 0.5rem; }

.field-error { color: var(--danger); font-size: 0.88rem; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

/* ---------- deck grid ---------- */

.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
}

.deck-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.18s ease;
  font-family: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 10rem;
}

.deck-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px var(--shadow-hover); }

.deck-card h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.25;
}

.deck-card .deck-desc {
  color: var(--ink-soft);
  font-size: 0.88rem;
  flex: 1;
}

.empty-note { color: var(--ink-soft); font-style: italic; }

/* ---------- admin editor ---------- */

.editable-title-wrap { flex: 1; min-width: 16rem; }

.title-input {
  width: 100%;
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 0.1rem 0;
}
.title-input:focus { outline: none; border-bottom-color: var(--accent); }

.subtitle-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink-soft);
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  padding: 0.1rem 0;
  margin-top: 0.4rem;
}
.subtitle-input:focus { outline: none; border-bottom-color: var(--accent); }

.card-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2rem 0 1rem;
}

.card-list { display: flex; flex-direction: column; gap: 0.75rem; }

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1.25rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  box-shadow: 0 2px 8px var(--shadow-color);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.card-row .side { min-width: 0; }

.card-row .side p {
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

.card-row .side .mono-label { display: block; margin-bottom: 0.2rem; }

.card-row-actions { display: flex; gap: 0.5rem; }

.icon-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1px solid var(--hairline);
  background: none;
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 2rem;
  width: min(30rem, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 32px var(--shadow-hover);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.modal::backdrop { background: var(--modal-backdrop); backdrop-filter: blur(2px); transition: backdrop-filter 0.3s ease; }

.modal-form { display: flex; flex-direction: column; gap: 1.25rem; }

/* ---------- study view ---------- */

.study { max-width: 40rem; margin: 0 auto; }

.study-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}
.study-head .eyebrow { margin-bottom: 0; }

.progress-track {
  height: 2px;
  background: var(--hairline);
  border-radius: 2px;
  margin-bottom: 2.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.flashcard-stage { perspective: 1400px; }

.flashcard {
  width: 100%;
  min-height: 20rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  color: inherit;
  display: block;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 20rem;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 6px 18px var(--shadow-color);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.flashcard-face p {
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.35;
}

.flashcard-back { transform: rotateY(180deg); border-color: var(--accent); }

.flip-hint {
  position: absolute;
  bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  opacity: 0.7;
}

.study-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.kbd-hint {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
  background: var(--surface);
  margin: 0 0.1rem;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ---------- responsive ---------- */

@media (max-width: 600px) {
  .view { padding: 2.5rem 1.25rem; }
  .topbar { padding: 1rem 1.25rem; }
  .card-row { grid-template-columns: 1fr; gap: 0.75rem; }
  .card-row-actions { justify-content: flex-end; }
}

/* ---------- theme toggler ---------- */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }

html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }

/* Keep icon svg colors aligned with theme text */
.icon-round svg {
  stroke: currentColor;
  transition: transform 0.3s ease;
}

.icon-round:hover svg {
  transform: rotate(15deg);
}

