/*
 | Arkansas Reading Vine — portal shell.
 |
 | MOBILE-FIRST, per CLAUDE.md "Responsive": base rules target the phone, and
 | the desktop layout is layered on at >=900px. The left nav is a drawer by
 | default and only becomes a permanent sidebar on wide screens.
 |
 | Tokens come from brand.css.
 */

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

body.rv-body { margin: 0; }

.rv-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================== top bar == */

.rv-topbar {
  background: var(--rv-primary);
  color: #fff;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  box-shadow: var(--rv-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 60;
}

.rv-topbar__logo {
  height: 36px; width: 36px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
  flex: 0 0 auto;
}

.rv-topbar__titles { min-width: 0; }

.rv-topbar__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The tagline is the first thing to go on a narrow phone. */
.rv-topbar__tagline { display: none; font-size: 11.5px; color: var(--rv-gold); font-weight: 500; }

.rv-topbar__spacer { flex: 1 1 auto; }

.rv-topbar__user { display: none; font-size: 14px; color: rgba(255,255,255,.92); }

/* ---- Notification bell (Phase 7) ----
   Sits on the green topbar, so it is drawn in white like the burger. >=42px
   touch target per CLAUDE.md's mobile rules, and visible at every width: the
   bell is the one control a tutor on a phone is most likely to want. */
.rv-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #fff;
  text-decoration: none;
}

.rv-bell:hover, .rv-bell:focus-visible { background: rgba(255,255,255,.14); }

.rv-bell svg { width: 21px; height: 21px; }

/* Amber, not red: an unread message is something to look at, not an alarm.
   Red is reserved for overdue in the compliance screens, and a bell that
   shouts the same way a missed 990 does devalues both. */
.rv-bell__count {
  position: absolute;
  top: 3px; right: 1px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--rv-amber, #d9a441);
  color: #3a2f12;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--rv-primary, #3b755f);
}

/* ---- Message centre ---- */

.rv-msg {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--rv-line, #e4ebe6);
  text-decoration: none;
  color: inherit;
}

.rv-msg:last-child { border-bottom: 0; }
.rv-msg:hover { background: var(--rv-bg, #f3f6f3); }

/* The unread marker is a left rail plus a tinted ground, never colour alone —
   a red/green dot is invisible to a good proportion of readers. */
.rv-msg--unread {
  background: rgba(217, 164, 65, .07);
  box-shadow: inset 3px 0 0 var(--rv-amber, #d9a441);
}

.rv-msg__dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-top: 5px;
  flex: 0 0 auto;
}

.rv-msg__title { font-weight: 700; font-size: 14.5px; margin: 0 0 2px; }
.rv-msg__body  { margin: 0; font-size: 13.5px; color: var(--rv-muted, #5b6b63); }
.rv-msg__when  { font-size: 12px; color: var(--rv-muted, #5b6b63); white-space: nowrap; }

/* Hamburger: >=40px touch target, hidden once the sidebar is permanent. */
.rv-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: rgba(255,255,255,.13);
  color: #fff;
  cursor: pointer;
  padding: 0;
}

.rv-burger:hover { background: rgba(255,255,255,.22); }
.rv-burger:focus-visible { outline: 3px solid var(--rv-leaf); outline-offset: 2px; }
.rv-burger svg { width: 22px; height: 22px; display: block; }

/* ================================================================ shell == */

.rv-shell { display: block; }

/* ---- Left nav: a drawer on phones/tablets ---- */

.rv-nav {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(84vw, 300px);
  background: var(--rv-surface);
  border-right: 1px solid var(--rv-border);
  z-index: 80;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  transform: translateX(-100%);
  transition: transform .22s ease;
  visibility: hidden;
}

/* Padding lives on the inner wrapper so that at desktop widths the nav element
   itself can stretch the full page height (background + border reach the
   bottom) while only this inner block sticks and scrolls. */
.rv-nav__inner { padding: 14px 12px 28px; }

.rv-nav[data-open="true"] { transform: translateX(0); visibility: visible; }

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  .rv-nav, .rv-backdrop { transition: none; }
}

.rv-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--rv-border);
  margin-bottom: 8px;
}

.rv-nav__brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.rv-nav__brand img { height: 32px; width: 32px; object-fit: contain; }
.rv-nav__brand span { font-weight: 700; font-size: 14px; color: var(--rv-ink); }

.rv-nav__close {
  width: 40px; height: 40px;
  border: 0; border-radius: 9px;
  background: var(--rv-bg);
  color: var(--rv-ink);
  cursor: pointer;
  flex: 0 0 auto;
}
.rv-nav__close:focus-visible { outline: 3px solid var(--rv-leaf); outline-offset: 2px; }

.rv-nav__group {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--rv-muted);
  padding: 16px 10px 6px;
}

.rv-nav__link {
  display: flex; align-items: center; gap: 11px;
  /* >=40px touch target */
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--rv-ink);
  text-decoration: none;
  font-size: 15px; font-weight: 500;
  border-left: 3px solid transparent;
}

.rv-nav__link:hover { background: var(--rv-bg); }
.rv-nav__link:focus-visible { outline: 3px solid var(--rv-leaf); outline-offset: -2px; }

.rv-nav__link--active {
  background: rgba(59,117,95,.10);
  color: var(--rv-primary-dark);
  font-weight: 700;
  border-left-color: var(--rv-gold);
}

.rv-nav__icon { width: 20px; height: 20px; flex: 0 0 auto; }

.rv-nav__foot { margin-top: 18px; padding: 12px 10px 0; border-top: 1px solid var(--rv-border); }

/* ---- Backdrop ---- */

.rv-backdrop {
  position: fixed; inset: 0;
  background: rgba(22,22,63,.48);
  z-index: 70;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease;
  border: 0; padding: 0; margin: 0;
  width: 100%; height: 100%;
  cursor: pointer;
}

.rv-backdrop[data-open="true"] { opacity: 1; visibility: visible; }

/* Stop the page scrolling behind an open drawer. */
body[data-nav-open="true"] { overflow: hidden; }

/* ---- Main ---- */

.rv-main { padding: 18px 14px 40px; min-width: 0; }

/* ============================================== desktop: permanent nav == */

@media (min-width: 900px) {
  .rv-topbar { min-height: 62px; padding: 0 20px; }
  .rv-topbar__logo { height: 40px; width: 40px; }
  .rv-topbar__title { font-size: 16.5px; }
  .rv-topbar__tagline { display: block; }
  .rv-topbar__user { display: inline; }

  .rv-burger { display: none; }

  /* align-items: stretch (the default) lets the nav column run the full height
     of the page, so its white background and right border never stop short of
     the footer on a long page. */
  .rv-shell { display: flex; align-items: stretch; }

  .rv-nav {
    position: static;
    height: auto;
    width: 248px;
    flex: 0 0 248px;
    transform: none;
    visibility: visible;
    overflow: visible;
    z-index: 1;
  }

  /* The sticky, independently scrolling part. */
  .rv-nav__inner {
    position: sticky;
    top: 62px;
    max-height: calc(100vh - 62px);
    overflow-y: auto;
    padding: 18px 12px 28px;
  }

  .rv-nav__head { display: none; }
  .rv-backdrop { display: none; }

  .rv-main { flex: 1 1 auto; padding: 26px 30px 60px; }

  body[data-nav-open="true"] { overflow: auto; }
}

/* ================================================================ bits === */

.rv-page-head { margin: 0 0 18px; }
.rv-page-head h1 { margin: 0 0 4px; font-size: 22px; }
@media (min-width: 900px) { .rv-page-head h1 { font-size: 26px; } }
.rv-page-head p { margin: 0; color: var(--rv-muted); font-size: 14.5px; }

.rv-card {
  background: var(--rv-surface);
  border: 1px solid var(--rv-border);
  border-radius: 14px;
  box-shadow: var(--rv-shadow-sm);
  padding: 18px;
}

@media (min-width: 900px) { .rv-card { padding: 22px; } }

/* Wide content (tables) scrolls inside its card, never the page body. */
.rv-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rv-scroll-x table { min-width: 560px; width: 100%; border-collapse: collapse; }

.rv-muted { color: var(--rv-muted); }

/* ---- Stat tiles: 1 col phone, 2 col tablet, 4 col desktop ---- */

.rv-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 560px) { .rv-stats { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .rv-stats { grid-template-columns: repeat(4, 1fr); } }

.rv-stat {
  background: var(--rv-surface);
  border: 1px solid var(--rv-border);
  border-left: 4px solid var(--rv-primary);
  border-radius: 12px;
  padding: 15px 16px;
  box-shadow: var(--rv-shadow-sm);
}

.rv-stat--gold { border-left-color: var(--rv-gold); }
.rv-stat--amber { border-left-color: var(--rv-amber); }
.rv-stat--leaf { border-left-color: var(--rv-leaf); }

.rv-stat__label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--rv-muted); margin: 0 0 6px;
}

.rv-stat__value { font-size: 27px; font-weight: 900; line-height: 1; color: var(--rv-ink); margin: 0; }
.rv-stat__hint { font-size: 12.5px; color: var(--rv-muted); margin: 6px 0 0; }

/* ---- Two-column sections stack below 900px ---- */

.rv-cols { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .rv-cols { grid-template-columns: 2fr 1fr; gap: 20px; } }

/*
 * A grid item defaults to min-width:auto, which means it refuses to shrink
 * below its content. A .rv-scroll-x table inside one therefore pushed the whole
 * PAGE wide instead of scrolling inside its own card: at 390px the finance
 * panel made the document 593px and the entire dashboard scrolled sideways,
 * which is exactly what CLAUDE.md says must not happen. min-width:0 lets the
 * item shrink so the overflow container can do its job.
 */
.rv-cols > * { min-width: 0; }

/* ---- Forms go single-column on small screens ---- */

.rv-form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .rv-form-grid { grid-template-columns: 1fr 1fr; } }
.rv-form-grid .rv-field--full { grid-column: 1 / -1; }

.rv-field label {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--rv-ink); margin-bottom: 5px;
}

.rv-input, .rv-select, .rv-textarea {
  width: 100%;
  min-height: 44px;              /* touch target */
  padding: 10px 12px;
  border: 1px solid var(--rv-border);
  border-radius: 9px;
  font-family: var(--rv-font);
  font-size: 15px;               /* >=16px avoids iOS zoom-on-focus; 15 is a compromise with density */
  color: var(--rv-ink);
  background: #fff;
}

.rv-textarea { min-height: 92px; resize: vertical; }

.rv-input:focus-visible, .rv-select:focus-visible, .rv-textarea:focus-visible {
  outline: 3px solid var(--rv-leaf); outline-offset: 1px; border-color: var(--rv-primary);
}

.rv-error { color: #b4322c; font-size: 12.5px; margin-top: 4px; }

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

.rv-verse {
  position: relative;
  background: linear-gradient(135deg, var(--rv-primary), var(--rv-primary-dark));
  color: #fff;
  border-radius: 14px;
  padding: 18px 18px 18px 52px;
  margin-bottom: 20px;
  box-shadow: var(--rv-shadow-sm);
  overflow: hidden;
}

.rv-verse__mark {
  position: absolute;
  left: 12px; top: 2px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 62px;
  line-height: 1;
  color: var(--rv-gold);
  opacity: .95;
  user-select: none;
}

.rv-verse__text { margin: 0 0 7px; font-size: 15.5px; line-height: 1.5; }
@media (min-width: 900px) { .rv-verse__text { font-size: 16.5px; } }

.rv-verse__ref {
  margin: 0; font-size: 12.5px; font-weight: 700;
  color: var(--rv-gold); letter-spacing: .03em;
}

/* ---- Badges / chips ---- */

.rv-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.6;
  white-space: nowrap;
}

/* ---- Empty state ---- */

.rv-empty { text-align: center; padding: 30px 16px; color: var(--rv-muted); }
.rv-empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: 10px; }

/* ---- Status pills (list filters) ---- */

.rv-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.rv-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;                /* touch target */
  padding: 8px 13px;
  border: 1px solid var(--rv-border);
  border-radius: 999px;
  background: var(--rv-surface);
  color: var(--rv-ink);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.rv-pill:hover { background: var(--rv-bg); }
.rv-pill:focus-visible { outline: 3px solid var(--rv-leaf); outline-offset: 2px; }
.rv-pill--on { font-weight: 700; box-shadow: inset 0 0 0 1px currentColor; }

.rv-pill__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.rv-pill__count {
  font-size: 12px;
  font-weight: 700;
  opacity: .72;
  margin-left: 2px;
}

/* ---- Search bar ---- */

.rv-searchbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.rv-searchbar .rv-input { flex: 1 1 240px; min-width: 0; }

/* ---- Tables inside cards ---- */

.rv-scroll-x table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--rv-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--rv-border);
  white-space: nowrap;
}

.rv-scroll-x table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rv-border);
  vertical-align: top;
  font-size: 14.5px;
}

.rv-scroll-x table tr:last-child td { border-bottom: 0; }
.rv-scroll-x table tbody tr:hover { background: var(--rv-bg); }

/* ---- Definition lists (detail pages) ---- */

.rv-dl { margin: 0; }

.rv-dl__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rv-border);
}

.rv-dl__row:last-child { border-bottom: 0; }

.rv-dl dt {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--rv-muted);
}

.rv-dl dd { margin: 0; font-size: 14.5px; white-space: pre-line; }

@media (min-width: 700px) {
  .rv-dl__row { grid-template-columns: 220px 1fr; gap: 14px; align-items: baseline; }
}

/* ---- Masked PII ---- */

.rv-masked {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .06em;
  color: var(--rv-muted);
  background: var(--rv-bg);
  border: 1px dashed var(--rv-border);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 13px;
  display: inline-block;
}

/* ---- Document / resource card grid ---- */

.rv-doc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 620px)  { .rv-doc-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .rv-doc-grid { grid-template-columns: repeat(3, 1fr); } }

.rv-doc {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .05s ease;
}

.rv-doc:hover { border-color: var(--rv-primary); }
.rv-doc:active { transform: translateY(1px); }
.rv-doc:focus-visible { outline: 3px solid var(--rv-leaf); outline-offset: 2px; }
.rv-doc__icon { font-size: 24px; flex: 0 0 auto; line-height: 1.2; }

/* ---- Rich text (agenda / minutes) ---- */

.rv-rich { font-size: 15px; line-height: 1.6; }
.rv-rich :first-child { margin-top: 0; }
.rv-rich :last-child { margin-bottom: 0; }
.rv-rich h1, .rv-rich h2, .rv-rich h3 { font-size: 16px; margin: 18px 0 8px; }
.rv-rich p { margin: 0 0 10px; }
.rv-rich ul, .rv-rich ol { margin: 0 0 10px; padding-left: 22px; }
.rv-rich li { margin-bottom: 4px; }
.rv-rich blockquote {
  margin: 0 0 10px; padding: 6px 14px;
  border-left: 3px solid var(--rv-gold); color: var(--rv-muted);
}
.rv-rich table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.rv-rich th, .rv-rich td { border: 1px solid var(--rv-border); padding: 6px 8px; text-align: left; }

/* Audio player fills the card on every width. */
audio { width: 100%; max-width: 100%; }

/* ---- New-mail banner (dashboard) ----
 |
 | Deliberately the verse banner's sibling rather than its twin: same rounded
 | card, same shadow, same place in the stack — but GOLD instead of forest
 | green, because green on green would read as one long header and this is the
 | half that wants acting on. Gold is already the portal's call-to-action
 | colour, so it says "there is something here" in the vocabulary the rest of
 | the app has taught.
 |
 | Ships hidden and stays hidden unless the after-render fetch says otherwise;
 | [hidden] is respected explicitly because the flex display would otherwise
 | override it.
*/
.rv-newmail {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--rv-gold), var(--rv-amber));
  color: #3a2f12;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--rv-shadow-sm);
}

.rv-newmail[hidden] { display: none; }

.rv-newmail__icon { width: 24px; height: 24px; flex: 0 0 auto; }

.rv-newmail__text {
  margin: 0;
  flex: 1 1 200px;
  font-weight: 700;
  font-size: 15.5px;
}

/* The gold button on a gold ground would disappear, so the call to action
   inverts to the brand green instead. */
.rv-newmail__open {
  flex: 0 0 auto;
  background: var(--rv-primary-dark);
  color: #fff;
  min-height: 40px;
  padding: 9px 16px;
  font-size: 14px;
}

.rv-newmail__open:hover { background: var(--rv-ink); }

.rv-newmail__dismiss {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  background: transparent;
  color: #3a2f12;
  cursor: pointer;
  border-radius: 8px;
  /* CLAUDE.md: touch targets >= 40px, even for a small × */
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .75;
}

.rv-newmail__dismiss:hover { opacity: 1; background: rgba(58, 47, 18, .1); }
.rv-newmail__dismiss svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------------------
   Pager
   ---------------------------------------------------------------------------
   Paired with resources/views/vendor/pagination/rv.blade.php, which replaced
   Laravel's default `pagination::tailwind`. That default draws its previous
   and next arrows as inline <svg> sized only by Tailwind utility classes; this
   portal does not load Tailwind, so each arrow rendered at its intrinsic size
   — an outsized navy chevron under every paginated list. Text arrows have no
   intrinsic size to get wrong.
*/

.rv-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.rv-pager__step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--rv-border);
  border-radius: var(--rv-radius);
  background: var(--rv-surface);
  color: var(--rv-ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.rv-pager__step:hover { border-color: var(--rv-primary); color: var(--rv-primary-dark); }
.rv-pager__step:focus-visible { outline: 3px solid var(--rv-leaf); outline-offset: 2px; }

.rv-pager__step--off { opacity: .45; cursor: not-allowed; }
.rv-pager__step--off:hover { border-color: var(--rv-border); color: var(--rv-ink); }

.rv-pager__where { font-size: 13.5px; color: var(--rv-muted); }
