/* ------------------------------------------------------------------------- */
/* Rota Alchemica — mobile navigation                                         */
/*                                                                            */
/* Hidden entirely on desktop (the sidebar stays authoritative above 900px).  */
/* On small screens, once rota_nav.js adds body.rota-nav-active, the sidebar  */
/* link grid is replaced by the quiescent coin + wheel + Menu sheet. Without  */
/* JS the existing mobile nav grid keeps working untouched.                   */
/* ------------------------------------------------------------------------- */

.rota-nav {
  display: none;
}

@media (max-width: 900px) {
  body.rota-nav-active .rota-nav {
    display: block;
  }

  /* Collapse the old mobile nav grid into a compact brand strip. */
  body.rota-nav-active .sidebar .nav-list,
  body.rota-nav-active .sidebar .nav-section-label {
    display: none;
  }

  body.rota-nav-active .sidebar {
    padding: 14px 22px;
    min-height: auto;
  }

  body.rota-nav-active .sidebar .brand {
    margin-bottom: 0;
  }

  /* Keep the last lines of content clear of the resting coin. */
  body.rota-nav-active .content {
    padding-bottom: 96px;
  }

  body.rota-nav-lock {
    overflow: hidden;
  }

  /* ---------- The resting coin ---------- */
  .rota-fab {
    appearance: none;
    border: 0;
    font: inherit;
    font-family: inherit;
    cursor: pointer;
    position: fixed;
    left: 50%;
    bottom: calc(-24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: 62px;
    height: 62px;
    border-radius: 50%;
    z-index: 1100;
    color: var(--gold, #b68b3c);
    background: rgba(255, 250, 240, 0.72);
    border: 1.5px solid var(--gold, #b68b3c);
    box-shadow: 0 -2px 10px rgba(79, 56, 38, 0.18);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    transition:
      transform 260ms cubic-bezier(0.34, 1.4, 0.64, 1),
      opacity 260ms ease,
      background 200ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .rota-fab::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    border: 1px dashed rgba(150, 112, 44, 0.5);
  }

  .rota-fab-a {
    display: block;
    font-size: 1.28rem;
    font-weight: 700;
    font-style: italic;
    color: var(--brown, #4f3826);
    transform: translateY(-13px);
  }

  .rota-fab:active {
    transform: translateX(-50%) scale(0.94);
  }

  .rota-fab:focus-visible {
    outline: 3px solid var(--brown, #4f3826);
    outline-offset: 3px;
  }

  /* Quiescent: the coin sinks into the wax while the student reads. */
  .rota-fab.dim {
    transform: translateX(-50%) translateY(30%) scale(0.9);
    opacity: 0.48;
  }

  .rota-nav.rota-open .rota-fab,
  .rota-nav.omnia-open .rota-fab {
    opacity: 0;
    pointer-events: none;
  }

  /* ---------- Scrim ---------- */
  .rota-scrim {
    position: fixed;
    inset: 0;
    z-index: 1110;
    border: 0;
    padding: 0;
    cursor: pointer;
    background: linear-gradient(to bottom, rgba(46, 32, 18, 0.28), rgba(46, 32, 18, 0.62));
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms ease;
  }

  .rota-nav.rota-open .rota-scrim,
  .rota-nav.omnia-open .rota-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  /* ---------- The wheel ---------- */
  .rota-stage {
    position: fixed;
    inset: 0;
    z-index: 1120;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    touch-action: none;
    transition: opacity 240ms ease, visibility 0s linear 240ms;
  }

  .rota-nav.rota-open .rota-stage {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 240ms ease, visibility 0s;
  }

  /* The wheel steps aside while the full Menu sheet is open. */
  .rota-nav.omnia-open .rota-stage {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 240ms ease, visibility 0s linear 240ms;
  }

  .rota-disc {
    position: absolute;
    width: 640px;
    height: 640px;
    pointer-events: none;
    color: var(--gold, #b68b3c);
    opacity: 0.9;
  }

  .rota-disc-spin {
    transform-origin: 50% 50%;
    animation: rota-slow 140s linear infinite;
  }

  @keyframes rota-slow {
    to { transform: rotate(360deg); }
  }

  .rota-item {
    appearance: none;
    border: 0;
    font: inherit;
    font-family: inherit;
    cursor: pointer;
    position: absolute;
    width: 58px;
    height: 58px;
    margin: -29px 0 0 -29px;
    border-radius: 50%;
    background: var(--paper, #fffaf0);
    border: 1px solid var(--gold, #b68b3c);
    color: #96702c;
    display: grid;
    place-items: center;
    box-shadow: 0 4px 12px rgba(46, 32, 18, 0.3);
    -webkit-tap-highlight-color: transparent;
  }

  .rota-item svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
  }

  .rota-item:focus-visible {
    outline: 3px solid var(--paper, #fffaf0);
    outline-offset: 2px;
  }

  .rota-item.sel {
    background: radial-gradient(circle at 34% 28%, #cfa557, #b68b3c 55%, #8a6427 100%);
    color: var(--paper, #fffaf0);
    border-color: rgba(255, 250, 240, 0.6);
    box-shadow: 0 6px 18px rgba(46, 32, 18, 0.45), 0 0 0 6px rgba(182, 139, 60, 0.25);
  }

  .rota-item-tag {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--parchment, #efe3c8);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 160ms ease;
    pointer-events: none;
  }

  .rota-item.sel .rota-item-tag {
    opacity: 1;
  }

  .rota-hub {
    appearance: none;
    border: 0;
    font: inherit;
    font-family: inherit;
    cursor: pointer;
    position: absolute;
    left: 50%;
    bottom: calc(-46px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: 172px;
    height: 172px;
    border-radius: 50%;
    z-index: 5;
    color: var(--paper, #fffaf0);
    background: radial-gradient(circle at 36% 26%, #6d4f33, var(--brown, #4f3826) 58%, #332415 100%);
    border: 1.5px solid var(--gold, #b68b3c);
    box-shadow: 0 -6px 24px rgba(20, 12, 5, 0.5), inset 0 1px 2px rgba(255, 250, 240, 0.25);
    text-align: center;
    -webkit-tap-highlight-color: transparent;
  }

  .rota-hub:focus-visible {
    outline: 3px solid var(--paper, #fffaf0);
    outline-offset: 3px;
  }

  .rota-hub-label {
    display: block;
    font-size: 1.18rem;
    font-weight: 700;
    margin-top: -66px;
  }

  .rota-hub-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.62rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--gold, #b68b3c);
  }

  .rota-hub-hint::before { content: "\00b7\0020"; }
  .rota-hub-hint::after { content: "\0020\00b7"; }

  .rota-close {
    appearance: none;
    background: rgba(255, 250, 240, 0.12);
    border: 1px solid rgba(255, 250, 240, 0.55);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    position: absolute;
    right: 18px;
    top: calc(18px + env(safe-area-inset-top, 0px));
    z-index: 5;
    -webkit-tap-highlight-color: transparent;
  }

  .rota-close::before,
  .rota-close::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 1.6px;
    background: var(--paper, #fffaf0);
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .rota-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .rota-close:focus-visible {
    outline: 2px solid var(--paper, #fffaf0);
    outline-offset: 2px;
  }

  /* The motto rides above the hub. */
  .rota-help {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(148px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    text-align: center;
    font-size: 0.78rem;
    font-style: italic;
    letter-spacing: 0.08em;
    color: var(--parchment, #efe3c8);
    opacity: 0.75;
    pointer-events: none;
  }

  /* ---------- Menu sheet ---------- */
  .rota-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1130;
    background: var(--paper, #fffaf0);
    border-radius: 24px 24px 0 0;
    border: 1px solid var(--line, #dcccae);
    border-bottom: 0;
    box-shadow: 0 -18px 44px rgba(46, 32, 18, 0.3);
    transform: translateY(104%);
    visibility: hidden;
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 320ms;
    padding: 10px 18px calc(26px + env(safe-area-inset-bottom, 8px));
    max-height: 84vh;
    max-height: 84dvh;
    overflow-y: auto;
  }

  .rota-nav.omnia-open .rota-sheet {
    transform: translateY(0);
    visibility: visible;
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
  }

  .rota-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--beige, #d8c59f);
    margin: 2px auto 10px;
  }

  .rota-sheet-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 2px 14px;
  }

  .rota-rule {
    flex: 1;
    height: 1px;
    background: var(--line, #dcccae);
  }

  .rota-sheet-top h2 {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #96702c;
    white-space: nowrap;
  }

  .rota-sheet-back {
    appearance: none;
    background: var(--cream, #f6f0e3);
    border: 1px solid var(--line, #dcccae);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex: 0 0 auto;
    -webkit-tap-highlight-color: transparent;
  }

  .rota-sheet-back::before {
    content: "";
    position: absolute;
    left: 55%;
    top: 50%;
    width: 9px;
    height: 9px;
    border-left: 2px solid var(--brown-soft, #74563c);
    border-bottom: 2px solid var(--brown-soft, #74563c);
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .rota-sheet-back:focus-visible {
    outline: 2px solid var(--gold, #b68b3c);
    outline-offset: 2px;
  }

  .rota-module-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .rota-module {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border: 1px solid var(--line, #dcccae);
    border-radius: 13px;
    background: var(--cream, #f6f0e3);
    color: inherit;
    text-decoration: none;
    min-height: 58px;
    transition: background 150ms ease, border-color 150ms ease, transform 120ms ease;
  }

  .rota-module:active {
    transform: scale(0.97);
  }

  .rota-module:focus-visible {
    outline: 2px solid var(--gold, #b68b3c);
    outline-offset: 2px;
  }

  .rota-module.active {
    background: linear-gradient(135deg, #f3e7cb, #eeddb9);
    border-color: var(--gold, #b68b3c);
  }

  .rota-module.muted {
    opacity: 0.55;
  }

  .rota-roundel {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--gold, #b68b3c);
    background: var(--paper, #fffaf0);
    display: grid;
    place-items: center;
    color: #96702c;
  }

  .rota-roundel svg {
    width: 19px;
    height: 19px;
  }

  .rota-m-name {
    font-weight: 600;
    font-size: 0.94rem;
    line-height: 1.2;
  }

  .rota-m-sub {
    font-size: 0.72rem;
    font-style: italic;
    color: var(--brown-soft, #74563c);
  }

  .rota-module.active .rota-m-name::after {
    content: "\00b7";
    color: #96702c;
    margin-left: 5px;
    font-weight: 700;
  }

  .rota-sheet-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 2px 10px;
  }

  .rota-sheet-section span:not(.rota-rule) {
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--olive, #72764d);
    white-space: nowrap;
  }

  @media (prefers-reduced-motion: reduce) {
    .rota-fab,
    .rota-scrim,
    .rota-stage,
    .rota-sheet,
    .rota-module,
    .rota-item-tag {
      transition-duration: 1ms;
    }

    .rota-disc-spin {
      animation: none;
    }
  }
}
