/* ==========================================================================
 * InteFlow theme examples — structural stylesheet
 * --------------------------------------------------------------------------
 * This file owns layout and component structure only. Every colour, font and
 * corner radius comes from the CSS variables below, which each theme file
 * redefines. Swapping the theme = swapping one small `:root` block.
 *
 * Token groups
 *   ground      --bg --surface --surface-2 --sidebar-bg --row-hover
 *   ink         --text --text-muted --text-faint
 *   lines       --border --border-strong
 *   accent      --accent --accent-hover --accent-text --accent-soft
 *   warn        --warn --warn-soft --warn-text
 *   shape       --radius-sm/-md/-lg --shadow-sm/-md
 *   type        --font-ui --font-display --font-mono
 *               --tracking-label --btn-transform --title-weight
 * ========================================================================== */

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

:root {
  /* fallback tokens (Clear Blue) so a page still renders without a theme file */
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --sidebar-bg: #ffffff;
  --row-hover: #f7f9fc;

  --text: #0f1b2d;
  --text-muted: #4a5a70;
  --text-faint: #8593a6;

  --border: #e2e8f0;
  --border-strong: #c6d0dd;

  --accent: #0057b8;
  --accent-hover: #004690;
  --accent-text: #ffffff;
  --accent-soft: #e8f1fb;

  --warn: #b45309;
  --warn-soft: #fdf4e6;
  --warn-text: #7c4a08;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgb(15 27 45 / 0.06);
  --shadow-md: 0 6px 18px -8px rgb(15 27 45 / 0.35);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-display: var(--font-ui);
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;
  --tracking-label: 0.02em;
  --btn-transform: none;
  --title-weight: 600;
  --fast: 140ms ease;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ shell */

.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.col {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.content {
  width: 100%;
  max-width: 64rem;
  flex: 1;
  margin: 0 auto;
  padding: 2.5rem 1.375rem 3rem;
}

@media (min-width: 640px) {
  .content {
    padding: 3.5rem 2rem 4rem;
  }
}

/* --------------------------------------------------------------- sidebar */

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  width: 16rem;
  height: 100vh;
  flex-shrink: 0;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1.15rem;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.ic {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: auto;
}

.theme-pick {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.theme-pick-label {
  color: var(--text-faint);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.theme-pick select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
}

.sidebar-note {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 0.68rem;
  line-height: 1.65;
}

.sidebar-note strong {
  color: var(--text-muted);
  font-weight: 600;
}

.preview-back {
  color: var(--text-faint);
  font-size: 0.7rem;
  text-decoration: none;
  text-underline-offset: 3px;
}

.preview-back:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ---------------------------------------------------- narrow-screen chrome */

.mobilebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: none;
  align-items: center;
  gap: 0.5rem;
  height: 3.5rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.mobilebar-brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.icon-btn {
  display: grid;
  place-items: center;
  padding: 0.35rem;
  margin-left: -0.25rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(10 14 22 / 0.45);
}

@media (max-width: 1023px) {
  .mobilebar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 17rem;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-md);
  }

  .app.drawer-open .sidebar {
    transform: none;
  }
}

/* ------------------------------------------------------------------- hero */

.hero {
  display: grid;
  gap: 2rem;
  padding-bottom: 2.25rem;
}

@media (min-width: 768px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 3rem;
  }
}

.eyebrow {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.title {
  margin: 0.7rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5.6vw, 3.4rem);
  font-weight: var(--title-weight);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.lede {
  max-width: 31rem;
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.75;
}

.stats {
  display: flex;
  gap: 2.25rem;
  margin: 0;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
  .stats {
    padding-top: 0;
    border-top: 0;
    text-align: right;
  }
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-label {
  color: var(--text-faint);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: var(--title-weight);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-value.is-warn {
  color: var(--warn);
}

.placeholder-cta {
  margin: 1.6rem 0 0;
}

/* ----------------------------------------------------------------- banner */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0 0 2rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--warn-soft);
  color: var(--warn-text);
}

.banner-icon {
  display: flex;
  color: var(--warn);
}

.banner-body {
  flex: 1;
}

.banner-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.banner-text {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  opacity: 0.85;
}

.banner-dismiss {
  padding: 0.15rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
}

.banner-dismiss:hover {
  opacity: 1;
}

/* ------------------------------------------------------------ section head */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border-strong);
}

.section-title {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.section-note {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.7rem;
}

/* ---------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 0.35rem;
}

.search {
  display: flex;
  max-width: 20rem;
  flex: 1;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-faint);
}

.search input {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.search input::placeholder {
  color: var(--text-faint);
}

.search .ic {
  width: 0.95rem;
  height: 0.95rem;
}

.toolbar-count {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- exam list */

.exam-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.exam-row {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  align-items: start;
  gap: 0.3rem 1.1rem;
  padding: 1.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--fast);
}

.exam-row:hover {
  background: var(--row-hover);
}

@media (min-width: 640px) {
  .exam-row {
    grid-template-columns: 2.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.4rem;
  }
}

.exam-index {
  padding-top: 0.2rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 640px) {
  .exam-index {
    padding-top: 0;
  }
}

.exam-body {
  min-width: 0;
}

.exam-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.13rem;
  font-weight: var(--title-weight);
  letter-spacing: -0.01em;
}

.exam-title a {
  color: inherit;
  text-decoration: none;
}

.exam-title a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}

.exam-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
  margin: 0.35rem 0 0;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* Separator lives inside its own item, so a wrapped line never starts or
   ends with a stranded "·". */
.meta-item + .meta-item::before {
  content: "·";
  margin-right: 0.45rem;
}

.key-warn {
  color: var(--warn);
  font-weight: 600;
}

.exam-actions {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 0.8rem;
}

@media (min-width: 640px) {
  .exam-actions {
    grid-column: auto;
    justify-content: flex-end;
    margin-top: 0;
  }
}

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: var(--btn-transform);
  cursor: pointer;
  transition: background var(--fast), color var(--fast),
    border-color var(--fast);
}

.btn .ic {
  width: 0.9rem;
  height: 0.9rem;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

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

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  cursor: pointer;
}

.link:hover {
  color: var(--text);
}

/* ------------------------------------------------------- empty & skeleton */

.empty {
  margin: 0;
  padding: 3rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 2rem 0;
}

.skeleton-line {
  height: 0.8rem;
  border-radius: 999px;
  background: var(--surface-2);
}

.skeleton-line.w70 {
  width: 70%;
}

.skeleton-line.w60 {
  width: 60%;
}

.skeleton-line.w45 {
  width: 45%;
}

/* --------------------------------------------------------------- footline */

.footline {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
}

.footline p {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.68rem;
}

.footline p:first-child {
  padding-top: 1.4rem;
}

@media (min-width: 640px) {
  .footline {
    max-width: 64rem;
    margin: 2rem auto 0;
    width: 100%;
    padding: 0 2rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg);
  font-size: 0.78rem;
  box-shadow: var(--shadow-md);
  animation: toast-in 160ms ease-out;
}

.toast .ic {
  width: 0.95rem;
  height: 0.95rem;
}

.toast.is-out {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 200ms ease, transform 200ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
