/* =====================================================================
   OathReady — phone layer
   Loaded after app.css. Same passport look; this file only changes what
   a phone needs: thumb-sized targets, one-hand navigation, sheets that
   rise from the bottom, notch / home-bar spacing, and no sideways scroll.
   ===================================================================== */

:root {
  --bar-h: 54px;
  --bar: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  --tab: 62px;
}

/* ------------------------------ touch basics ------------------------------ */
html { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
body { overscroll-behavior-y: none; background-image: none; }
/* The paper texture sits on its own fixed layer: smooth scrolling on phones. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(24, 32, 58, .07) 1px, transparent 1.6px),
    repeating-radial-gradient(circle at 110% -10%, transparent 0 22px, rgba(39, 69, 155, .045) 22px 23px),
    repeating-radial-gradient(circle at -10% 110%, transparent 0 26px, rgba(199, 54, 47, .04) 26px 27px);
  background-size: 22px 22px, auto, auto;
}
a, button, summary, label, input, select, .navlink { touch-action: manipulation; }
button, .btn, .navlink, .tabs a, .qk, .mode, .cta, .gsec > summary, .qcard summary, .menu-item { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.l-short { display: none; }
.bar-more { display: none; }
.topbar { height: var(--bar); padding-top: env(safe-area-inset-top, 0px); }
.trail { overflow-x: clip; }
/* long words (web addresses in tips and notices) wrap instead of widening the page */
.panel, .tipcard, .notice, .toast, .gbody, .modal { overflow-wrap: break-word; }
.cols > * { min-width: 0; }
.wizard { min-height: calc(100dvh - var(--bar)); }

/* A finger has no hover: stop buttons from staying "lifted" after a tap. */
@media (hover: none) {
  .btn:hover { transform: none; box-shadow: 0 4px 0 var(--shadow); }
  .btn.sm:hover { box-shadow: 0 3px 0 var(--shadow); }
  .btn.link:hover { box-shadow: none; }
  .btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); }
  .btn.sm:active { transform: translateY(3px); }
  .btn.link:active { transform: none; box-shadow: none; }
  .btn[disabled], .btn[disabled]:active { transform: none; box-shadow: 0 4px 0 var(--shadow); }
  .cta:hover .btn { transform: none; box-shadow: 0 4px 0 #0D1226; }
  .cta:active .btn { transform: translateY(4px); box-shadow: 0 0 0 #0D1226; }
  .qk:hover, .mode:hover { transform: none; box-shadow: 0 4px 0 var(--shadow); }
  .qk:active, .mode:active { transform: translateY(4px); box-shadow: none; }
  .mode.off:hover { box-shadow: none; }
  .node-btn:hover { transform: none; box-shadow: 0 6px 0 var(--shadow); }
  .node-btn:active { transform: translateY(6px); box-shadow: 0 0 0 var(--shadow); }
  .opt:hover:not(:disabled) { background: var(--card); transform: none; box-shadow: 0 4px 0 var(--shadow); }
  .opt.sel:hover:not(:disabled) { background: var(--blue-soft); box-shadow: 0 4px 0 var(--shadow), inset 0 0 0 2px var(--blue); }
  .opt:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
  .navlink:not(.on):hover { color: var(--ink-2); background: none; }
  .barbtn:not(.add):not(.off):not(.rest):hover:not(:disabled) { background: var(--card); }
  .vword:hover { background: var(--paper); }
  .vword:active { background: var(--gold-soft); }
  /* 16px text boxes: iPhone will not zoom the page when you tap into one. */
  input, select, textarea, .note textarea { font-size: max(16px, 1em); }
}

/* ------------------------------ the menu sheet ------------------------------ */
.menu { display: grid; gap: .55rem; margin-top: 1rem; }
.menu-two { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.menu-item { display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 58px; padding: .55rem .9rem; text-align: left; border: 2px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink); box-shadow: 0 3px 0 var(--shadow); font-weight: 700; line-height: 1.2; transition: transform .08s, box-shadow .08s; }
.menu-item .ic { width: 1.45em; height: 1.45em; }
.menu-item span { min-width: 0; }
.menu-item small { display: block; font-weight: 400; color: var(--ink-2); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; }
.menu-item:active { transform: translateY(3px); box-shadow: none; }
.menu-item.rest { color: var(--ink-2); background: var(--paper); box-shadow: none; border-style: dashed; }
.menu-item.gold { background: var(--gold-soft); }
.menu-item em { margin-left: auto; font: 800 .8rem/1 var(--display); font-style: normal; background: var(--ink); color: var(--paper); padding: .35em .6em; border-radius: 99px; flex: none; }
.steps-ios { list-style: none; counter-reset: s; padding: 0; margin: 1rem 0 0; display: grid; gap: .7rem; text-align: left; }
.steps-ios li { counter-increment: s; display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: center; }
.steps-ios li::before { content: counter(s); width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--gold-soft); font: 800 .95rem/1 var(--display); }

/* ------------------------------ install card ------------------------------ */
.install { position: fixed; left: .7rem; right: .7rem; bottom: calc(var(--tab) + .8rem + env(safe-area-inset-bottom, 0px)); z-index: 32; display: flex; align-items: center; gap: .7rem; padding: .65rem .7rem .65rem .9rem; background: var(--ink); color: var(--paper); border-radius: 16px; box-shadow: 0 10px 26px rgba(0, 0, 0, .32); animation: rise .4s cubic-bezier(.2, .9, .3, 1) both; max-width: 520px; margin: 0 auto; }
.install-ic { font-size: 1.6rem; line-height: 1; flex: none; }
.install-t { flex: 1; min-width: 0; font-size: .86rem; line-height: 1.25; opacity: .9; }
.install-t b { display: block; font: 800 1rem/1.15 var(--display); opacity: 1; }
.install .btn { background: var(--gold); color: #18203A; border-color: #0D1226; box-shadow: 0 3px 0 #0D1226; flex: none; }
.install-x { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: inherit; opacity: .7; border-radius: 8px; flex: none; padding: 0; }
body.focus .install { display: none; }
@media (min-width: 821px) { .install { left: auto; right: 1rem; bottom: 1rem; width: 380px; margin: 0; } }
.offline-pill { display: inline-flex; align-items: center; gap: .35rem; font: 700 .68rem/1 var(--stampfont); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); border: 1.5px solid var(--rule); border-radius: 6px; padding: .35em .5em .25em; margin-right: .2rem; flex: none; }

/* ------------------------------ phone and small tablet ------------------------------ */
@media (max-width: 820px) {
  .view { padding: 1.1rem max(1rem, env(safe-area-inset-right, 0px)) calc(var(--tab) + 2.4rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px)); }
  .page-h { margin-bottom: 1.2rem; }
  .lede { font-size: 1.02rem; }
  /* columns may shrink below their content, so nothing pushes the page sideways */
  .cols, .guide, .modes, .form { grid-template-columns: minmax(0, 1fr); }
  .panel, .gsec, .gbody { min-width: 0; overflow-wrap: break-word; }
  table.cmp { table-layout: fixed; }
  table.cmp th, table.cmp td { overflow-wrap: anywhere; }
  .factgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* bottom tabs: bigger icons, a stamped pill for the current page */
  .tabbar { gap: 2px; padding: .3rem max(.3rem, env(safe-area-inset-right, 0px)) calc(.3rem + env(safe-area-inset-bottom, 0px)) max(.3rem, env(safe-area-inset-left, 0px)); }
  .tabbar .navlink { min-height: 54px; justify-content: center; gap: .2rem; padding: .3rem .1rem; font-size: .68rem; font-weight: 700; border: 2px solid transparent; border-radius: 12px; }
  .tabbar .navlink .ic { width: 24px; height: 24px; }
  .tabbar .navlink.on { background: var(--gold-soft); border-color: var(--line); box-shadow: 0 2px 0 var(--shadow); }
  .tabbar .l-full { display: none; }
  .tabbar .l-short { display: inline; }
  .tabbar .navlink:active { transform: translateY(1px); }

  /* study deck: one swipeable row of filters instead of three stacked rows */
  .deckbar { padding: .6rem 0 .55rem; gap: .5rem; }
  .deckbar .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -1rem; padding: 0 1rem 2px; scroll-padding: 0 1rem; }
  .deckbar .chips::-webkit-scrollbar { display: none; }
  .chipbtn { flex: none; white-space: nowrap; min-height: 40px; padding: .3rem .9rem; }
  .qcard summary { min-height: 56px; }
  .qtools .btn.sm, .qtools .iconbtn.sm { min-height: 42px; }

  /* practice + guide: comfortable rows */
  .modes { gap: .8rem; }
  .gsec > summary { padding: .85rem .9rem; gap: .8rem; }
  .gbody { padding: 0 .9rem 1rem; }
  table.cmp { font-size: .9rem; }
  table.cmp th, table.cmp td { padding: .5rem .6rem; }

  /* a round in progress */
  .play-top { padding: .7rem 1rem .5rem; gap: .6rem; }
  .play-body { padding: .7rem 1rem 1.6rem; }
  .opt { min-height: 60px; }
  .foot-in { padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom, 0px)); }
  .foot-in > .btn.big { min-width: 46%; }
  .fb-body { max-height: 32dvh; }
  .tabs a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ------------------------------ top bar on a phone ------------------------------ */
/* (960px also covers a phone held sideways and a small tablet) */
@media (max-width: 960px) {
  .bar-x { display: none; }
  .bar-more { display: inline-flex; }
  .bar-in { gap: .45rem; padding: 0 max(.7rem, env(safe-area-inset-right, 0px)) 0 max(.7rem, env(safe-area-inset-left, 0px)); }
  .barbtn .lbl { display: none; }
  .barbtn { width: 42px; height: 42px; padding: 0; border-radius: 12px; }
  .barbtn .ic { width: 1.35em; height: 1.35em; }
  .bar-title { margin-left: .35rem; font-size: 1.08rem; letter-spacing: -.01em; color: var(--ink); }
  .savestate { margin-right: .1rem; }
}

/* ------------------------------ phone only ------------------------------ */
@media (max-width: 600px) {
  h1 { font-size: clamp(1.7rem, 7.6vw, 2.2rem); }
  .panel { padding: 1rem; box-shadow: 4px 4px 0 var(--shadow); margin-top: 1.1rem; }
  .cta { padding: 1.1rem; margin-top: 1.1rem; box-shadow: 5px 5px 0 var(--shadow); gap: .9rem; }
  .tiles, .quick { gap: .7rem; margin-top: 1.1rem; }
  .hero-top { align-items: center; }
  .hero h1 { font-size: clamp(1.5rem, 6.6vw, 2rem); }
  .ring { width: 92px; height: 92px; }
  .streak-num b { font-size: 2.6rem; }

  /* dialogs rise from the bottom, where the thumb already is */
  .overlay { padding: 0; place-items: end stretch; }
  .modal:not(.narrow) { width: 100%; max-height: 88dvh; border-width: 2px 0 0; border-radius: 24px 24px 0 0; box-shadow: none; padding: 1.5rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom, 0px)); animation: sheetup .32s cubic-bezier(.2, 1, .3, 1); overscroll-behavior: contain; }
  .modal:not(.narrow)::before { content: ''; display: block; width: 46px; height: 5px; border-radius: 99px; background: var(--rule); margin: -.7rem auto .9rem; }
  .modal.narrow { place-self: center; width: min(calc(100% - 2rem), 400px); }
  .lesson-sheet .row { margin-top: 1.2rem; }
  .qlist li { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .lesson-sheet .btn.big { width: 100%; }
  .allnotes-page header .btn { flex: none; }

  /* passport card keeps its photo-beside-details shape */
  .idcard { grid-template-columns: auto minmax(0, 1fr); justify-items: stretch; gap: 1rem; padding: 1.1rem; }
  .id-photo { width: 84px; height: 102px; font-size: 2.7rem; }
  .id-row b { font-size: 1.05rem; }
  .statgrid { gap: .55rem; margin-top: 1.1rem; }
  .stamps { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 1.1rem .3rem; }
  .stamp { width: 104px; }
  .stamp-ring { width: 76px; height: 76px; }
  .stamp-desc { max-width: 104px; }

  .unit-h h2 { font-size: 1.2rem; }
  .unit-ic { width: 48px; height: 48px; font-size: 1.6rem; }
  .sentence { margin: 1rem 0; }
  .engcard { padding: 1.3rem 1rem 1.5rem; }
  .wizard { padding: 1.2rem 1.1rem 2rem; justify-content: flex-start; }
  .wz-dots { margin: .6rem 0 1.2rem; }
  .seal { width: 128px; height: 128px; }
  .seal b { font-size: 2.4rem; }
  .note { width: 178px; }
}
@media (max-width: 360px) {
  /* a gentler zig-zag so lesson names stay inside a small screen */
  .node { transform: translateX(calc(var(--dx) * .65)); }
  .trailwrap > svg { transform: scaleX(.65); }
  .tabbar .navlink { font-size: .62rem; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { padding: .7rem .35rem; }
  .barbtn { width: 40px; height: 40px; }
  .install-ic { display: none; }
}
/* short, wide screens (phone turned sideways) */
@media (max-height: 480px) and (orientation: landscape) {
  .fb-body { max-height: 26dvh; }
  .modal:not(.narrow) { max-height: 96dvh; }
}

@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
