/* Shared mobile / learn-on-the-go layer for The Unruly.
   Loaded on every page (hub and practice rooms). */

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Readable UI text; decorative map labels may stay smaller. */
body, button, input, select, textarea, .btn, .chip, .opt, label {
  -webkit-tap-highlight-color: rgba(56, 140, 55, 0.25);
}
input, select, textarea {
  font-size: 16px !important; /* prevent iOS Safari focus-zoom */
  max-width: 100%;
}

/* Tap targets */
button, .btn, .chip, .opt, .unit, .menu-toggle,
input[type="button"], input[type="submit"],
#unruly-bar a, .site-nav a, .site-dock a, .mz-btn {
  min-height: 44px;
  min-width: 44px;
}
/* Checkboxes stay compact; the label provides the 44px hit area. */
input[type="checkbox"], input[type="radio"] {
  accent-color: #388C37;
  flex-shrink: 0;
}
.menu-toggle { padding: 0.55rem 0.9rem; }

/* Brand bar on wrapped rooms */
#unruly-bar {
  font-size: 16px !important;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
  padding-bottom: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#unruly-bar a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Hub header respects the notch */
.site-header {
  padding-top: env(safe-area-inset-top, 0px);
  min-height: calc(var(--header-h, 4.75rem) + env(safe-area-inset-top, 0px));
}

/* Sticky bottom dock — injected on hub-chrome pages */
.site-dock {
  display: none;
}
@media (max-width: 720px) {
  .site-dock {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    justify-content: space-around;
    align-items: stretch;
    gap: 0;
    background: #FFFFFF;
    border-top: 1px solid var(--rule, #D3DCD0);
    padding: 4px 8px max(8px, env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px -16px rgba(19, 47, 18, 0.28);
  }
  .site-dock a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    text-decoration: none;
    color: var(--ink-soft, #3D4A41);
    font-family: "Work Sans", "Segoe UI", system-ui, sans-serif;
    font-size: 16px;
    font-weight: 650;
    border-radius: 10px;
  }
  .site-dock a[aria-current="page"], .site-dock a:hover { color: var(--purple, #8922AA); }
  .site-dock a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--purple, #8922AA); }
  .site-dock .ico { font-size: 18px; line-height: 1; }
  /* leave room so content isn't hidden behind the dock */
  body.has-dock { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .site-footer { padding-bottom: 1.5rem; }
}

/* Hub chips & cards on a phone */
@media (max-width: 720px) {
  .chip { font-size: 16px; padding: 0.55rem 0.95rem; }
  .search input { font-size: 16px; min-height: 44px; }
  .hero-logo { width: min(16.5rem, 78vw); }
  .hero h1, .hero-tagline { font-size: clamp(0.92rem, 3.8vw, 1.15rem); letter-spacing: 0.1em; }
  .card h3 { font-size: 1.3rem; }
}

/* Poetry: don't pin a tall nav over the poem on a phone */
@media (max-width: 899px) {
  .poem-nav {
    position: static;
    max-height: none;
  }
  .poem-nav summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    list-style: none;
  }
  .poem-nav summary::-webkit-details-marker { display: none; }
  .poem-nav a { min-height: 44px; display: flex; align-items: center; }
}
@media (min-width: 900px) {
  .poem-nav summary { display: none; }
}

/* Times-table / world-explorer interiors */
.unit { min-height: 44px; }
.opt, .quiz-box .opt { min-height: 44px; font-size: 16px; }
.chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
input.ans { font-size: 2rem; min-height: 48px; max-width: 100%; }

/* Map zoom chrome */
.mz-wrap { position: relative; margin: 0 0 0.75rem; }
.mz-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin: 0 0 8px;
}
.mz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #B7C4B4;
  border-radius: 10px;
  background: #fff;
  color: #27211E;
  font: 650 18px/1 "Work Sans", "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}
.mz-btn:active { background: #EFFAE5; }
.mz-hint { font-size: 16px; color: #3D4A41; margin-right: auto; }
.mz-viewport {
  overflow: hidden;
  touch-action: none;
  border-radius: 16px;
  max-height: min(70vh, 640px);
  background: #d7ecf6;
  position: relative;
  cursor: grab;
}
.mz-viewport.is-panning { cursor: grabbing; }
.mz-inner {
  transform-origin: 0 0;
  will-change: transform;
}
.mz-inner svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  background: transparent;
}
.mz-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}
.mz-list button {
  font-size: 16px;
  min-height: 44px;
  padding: 8px 12px;
}

@media print {
  .site-dock, .mz-toolbar, body::before { display: none !important; }
  body.has-dock { padding-bottom: 0; }
}

/* Prefers reduced motion: still allow explicit zoom button jumps */
@media (prefers-reduced-motion: reduce) {
  .mz-inner { transition: none !important; }
}


/* Chrome typography and tap targets (all viewports) */
.mark { min-height: 44px; }
.site-nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 16px;
}
.crumb, .crumb a { font-size: 16px; }
.site-footer, .site-footer p, .site-footer a, .foot-links { font-size: 16px; }
.chip { font-size: 16px; min-height: 44px; }
.poem-nav a, #toc a { min-height: 44px; display: flex; align-items: center; font-size: 16px; }


/* Keep first screens usable above the dock */
@media (max-width: 720px) {
  .page-hero { padding: 1.35rem 0 0.85rem; }
  .page-hero .deck, .page-hero .lede { font-size: 1.02rem; margin-bottom: 0; }
  .section { padding-top: 1.5rem; }
}
@media (max-width: 420px) {
  .hero { padding: 1.15rem 0 1.1rem; }
  .hero-logo { width: min(14.5rem, 72vw); margin-bottom: 0.85rem; }
  .hero h1, .hero-tagline {
    font-size: clamp(0.88rem, 3.4vw, 1.05rem);
    letter-spacing: 0.08em;
    margin-bottom: 0.8rem;
  }
  .lede { font-size: 1rem; margin-bottom: 0.7rem; }
  .ornament { margin: 0.7rem 0 0.85rem; }
  .hero-actions { gap: 0.55rem; }
  .btn { padding: 0.7rem 1.15rem; }
}
@media (max-height: 500px) {
  .hero { padding: 0.7rem 0 0.6rem; }
  .hero-logo { width: min(12rem, 56vw); margin-bottom: 0.45rem; }
  .hero h1, .hero-tagline { font-size: 0.9rem; letter-spacing: 0.08em; margin-bottom: 0.45rem; }
  .lede { font-size: 0.98rem; margin-bottom: 0.45rem; }
  .ornament { display: none; }
  .kicker { margin-bottom: 0.35rem; }
  .page-hero { padding: 0.6rem 0 0.45rem; }
  .site-dock { display: none !important; }
  body.has-dock { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* Flex/grid children must be allowed to shrink so they don't poke past the viewport */
.wrap, .builder, .editor, .preview-card, .ed-row, .subject-item, .sheet-wrap {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}


/* First-screen typography: leave room above the dock for primary actions */
@media (max-width: 720px) {
  .course-main { padding: 0.85rem 0 2rem; }
  .crumb { margin: 0 0 0.2rem; }
  .page-title, .course-main h1.page-title { margin: 0 0 0.35rem; font-size: clamp(1.85rem, 8vw, 2.4rem); }
  .course-main .kicker, .page-hero .kicker { margin-bottom: 0.2rem; }
  .course-main .deck, .page-hero .deck { margin-bottom: 0.5rem; }
  .course-main .hero-actions { margin: 0.4rem 0 0.65rem !important; }
  .library-tools { margin-top: 0.55rem !important; }
  .course-main .prose { margin: 0.35rem 0 0.15rem !important; }
  .sheet-actions { margin: 0.35rem 0 0.8rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
}

@media (max-width: 420px) {
  .course-main .deck, .page-hero .deck { font-size: 1rem; }
}


/* Builder first-paint: keep the Edit panel (title + day pills) above the dock */
@media (max-width: 430px) {
  .page-hero .deck {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
@media (max-width: 380px) {
  .page-hero .crumb, .course-main .crumb { display: none; }
  .page-hero.compact-deck .deck { display: none; }
  .page-hero .deck {
    -webkit-line-clamp: 2;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
  }
}


/* Room chrome: purple band with a green edge, matching TurfMend's paired colors */
#unruly-bar {
  background: #502161;
  border-bottom: 3px solid #388C37;
  color: #fff;
  flex-wrap: nowrap;
}
#unruly-bar .cur {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#unruly-bar a { color: #fff; }
#unruly-bar a:hover { color: #ADD9AD; }
#unruly-bar .cur { color: #EAD4F2; }
#unruly-bar .word { color: #ADD9AD; }
