/* Mobile UI primitives — Atelier Mobile design.
   Only kicks in on narrow viewports via `@media (max-width: 880px)`.
   Uses the existing `--at-*` design tokens; does NOT touch desktop layouts. */

@media (max-width: 880px) {
  /* Mobile page background gradient */
  body {
    background:
      radial-gradient(60% 60% at 50% 0%, color-mix(in oklab, var(--at-brand) 6%, transparent) 0%, transparent 70%),
      var(--at-paper);
  }
}

/* -------- Mobile primitives (usable on any viewport) -------- */

/* Card — soft surface with hairline border and small shadow */
.m-card {
  background: var(--at-surface);
  border: 1px solid var(--at-line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15, 17, 20, 0.04);
}
.m-card + .m-card {
  margin-top: 12px;
}
.m-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Big serif display numbers */
.m-num {
  font-family: var(--at-serif);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.m-num.xl {
  font-size: 72px;
}
.m-num.lg {
  font-size: 48px;
}
.m-num.md {
  font-size: 32px;
}

/* Eyebrow */
.m-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--at-mute);
}

/* Chips */
.m-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--at-paper-2);
  color: var(--at-ink-2);
  border: 1px solid var(--at-line);
}
.m-chip.brand {
  background: var(--at-brand-soft);
  color: var(--at-brand);
  border-color: color-mix(in oklab, var(--at-brand) 18%, transparent);
}
.m-chip.good {
  background: var(--at-good-soft);
  color: var(--at-good);
  border-color: color-mix(in oklab, var(--at-good) 20%, transparent);
}
.m-chip.streak {
  background: var(--at-streak-soft);
  color: var(--at-streak);
  border-color: color-mix(in oklab, var(--at-streak) 22%, transparent);
}

/* Progress bar */
.m-bar {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: var(--at-line-2);
  overflow: hidden;
}
.m-bar > span {
  display: block;
  height: 100%;
  background: var(--at-brand);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Buttons */
.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  background: var(--at-surface);
  color: var(--at-ink);
  border: 1px solid var(--at-line);
  transition: transform 0.08s ease;
}
.m-btn:active {
  transform: scale(0.97);
}
.m-btn.primary {
  background: var(--at-ink);
  color: var(--at-paper);
  border-color: var(--at-ink);
}
.m-btn.brand {
  background: var(--at-brand);
  color: white;
  border-color: var(--at-brand);
  box-shadow: 0 4px 14px -4px color-mix(in oklab, var(--at-brand) 60%, transparent);
}
.m-btn.block {
  width: 100%;
}
.m-btn.sm {
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
}

/* Section header */
.m-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 4px 12px;
}
.m-section-title {
  font-family: var(--at-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.m-section-title i {
  font-style: italic;
  color: var(--at-brand);
}
.m-section-link {
  font-size: 12.5px;
  color: var(--at-brand);
  font-weight: 600;
}

/* Topic tile */
.m-topic-tile {
  border-radius: 18px;
  padding: 14px;
  background: var(--at-surface);
  border: 1px solid var(--at-line);
  text-align: left;
  position: relative;
  overflow: hidden;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.1s;
}
.m-topic-tile:active {
  transform: scale(0.98);
}

/* Grids */
.m-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.m-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* Screen transition */
.m-fade {
  animation: mFade 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes mFade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------- Mobile-only responsive tweaks (only < 880px) -------- */
@media (max-width: 880px) {
  /* Tab bar — floating glass pill */
  .m-tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    height: 68px;
    border-radius: 28px;
    background: color-mix(in oklab, var(--at-surface) 88%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--at-line);
    box-shadow:
      0 -2px 14px rgba(15, 17, 20, 0.04),
      0 14px 32px -12px rgba(15, 17, 20, 0.16);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    z-index: 30;
    padding: 6px;
    gap: 2px;
  }
  .m-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 20px;
    color: var(--at-mute);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 6px 4px;
    transition: color 0.15s, background 0.15s;
  }
  .m-tab.is-active {
    color: var(--at-brand);
    background: var(--at-brand-softer);
  }
  .m-tab > svg {
    transition: transform 0.15s;
  }
  .m-tab.is-active > svg {
    transform: translateY(-1px) scale(1.08);
  }
}

/* -------- Mobile top bar (floating title) -------- */
@media (max-width: 880px) {
  .m-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 16px 12px;
    background: color-mix(in oklab, var(--at-paper) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--at-line);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .m-topbar-title {
    font-family: var(--at-serif);
    font-weight: 400;
    font-size: 26px;
    letter-spacing: -0.02em;
    line-height: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-topbar-title i {
    font-style: italic;
    color: var(--at-brand);
  }
}
