/* Side rail (iterations 17–22). From 640 px the game tabs are a fixed column of square buttons on the
   left, like the owner's BeeFarm: violet rounded squares with a 32 px icon and a thick bottom edge;
   the current one has a light border and a warm glow. The name appears in a small tag to the right on
   hover / keyboard focus (and is always there for screen readers). Phones (< 640 px) keep the bottom
   dock, restyled with the same gray buttons. Built by js/ui/nav.js (#nav.is-rail). */

/* iteration 22: violet like the rest of the game (was dark gray) */
:root {
  --rail-bg: #1A1330;       /* the column */
  --rail-btn: #2A2050;      /* button face */
  --rail-btn-hi: #35295F;   /* hover */
  --rail-edge: #45367A;     /* border */
  --rail-drop: #0D081E;     /* the thick bottom edge */
  --rail-on: #5B3BD6;       /* current button face */
  --rail-on-edge: #E9DCFF;  /* current button border */
  --rail-on-drop: #2C1878;  /* current button bottom edge */
}

@media (min-width: 640px) {
  :root { --rail-w: 88px; }

  body:not([data-route="portada"]) .app { padding-left: var(--rail-w); }
  /* the page starts close to the column and, on wide screens, grows to fill the space beside it
     (wider shell, see below) instead of leaving an empty band on the right */
  body:not([data-route="portada"]) .view,
  body:not([data-route="portada"]) .site-foot { padding-left: 16px; }
  body:not([data-route="portada"]) .hud { padding-left: 16px; }

  /* the header has no tab row any more: room for the name next to the emblem */
  .hud-brand-text { display: inline; }
  .hud-brand { padding-right: var(--sp-2); }
  .hud-inner {
    grid-template-columns: auto minmax(0, 1fr) auto auto auto auto auto;
    grid-template-areas: "brand . qso power block player settings";
  }

  .nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--rail-w);
    z-index: 35;
    container-type: normal; /* the header's container queries must not shrink the rail */
    padding: 0;
    background: var(--rail-bg);
    box-shadow: inset -2px 0 0 #2A2148, 3px 0 0 var(--ink);
    overflow: visible; /* the name tags stick out to the right */
  }
  .nav-track {
    width: 100%;
    max-width: none;
    padding: 16px 0 20px;
  }
  .nav-list {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .nav-list li { flex: none; position: relative; }
  .nav-link {
    position: relative;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    width: 60px;
    height: 60px;
    min-height: 0;
    padding: 0;
    color: var(--text-2);
    background: var(--rail-btn);
    border: 2px solid var(--rail-edge);
    border-radius: 14px;
    box-shadow: 0 4px 0 var(--rail-drop), inset 0 2px 0 rgba(255, 255, 255, 0.06);
    transform: none;
    transition: background-color var(--t-fast) steps(2), transform 70ms steps(2);
  }
  .nav-link:hover { background: var(--rail-btn-hi); color: var(--text); }
  .nav-link:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--rail-drop), inset 0 2px 0 rgba(255, 255, 255, 0.06); }
  .nav-link[aria-current="page"] {
    color: #FFFFFF;
    background: var(--rail-on);
    border-color: var(--rail-on-edge);
    box-shadow: 0 4px 0 var(--rail-on-drop), 0 0 0 3px var(--ink), inset 0 2px 0 rgba(255, 255, 255, 0.14);
    transform: none;
  }
  .nav-link[aria-current="page"]:hover { background: var(--violet-face-hi); }
  .nav-icon { width: 32px; height: 32px; }
  .nav-icon .rr-sprite { opacity: 1; }
  .nav-link:hover .nav-icon { transform: translateY(-1px); }

  /* the name: a small dark tag to the right, on hover or keyboard focus */
  .nav-label {
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    max-width: none;
    padding: 6px 10px 5px;
    overflow: visible;
    white-space: nowrap;
    font-size: 17px;
    color: var(--text);
    background: var(--rail-bg);
    border: 2px solid var(--rail-edge);
    border-radius: 8px;
    box-shadow: 0 3px 0 var(--rail-drop);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--t-fast) steps(2), visibility var(--t-fast) steps(2);
  }
  .nav-link:hover .nav-label,
  .nav-link:focus-visible .nav-label { opacity: 1; visibility: visible; }

  /* the wallet sits a little apart at the bottom of the list */
  .nav-list li:last-child { margin-top: 8px; }

  /* the tutorial must not hide behind the rail */
  .tutorial { left: calc(var(--rail-w) + 16px); }

  /* ---- under the buttons (iteration 24, js/ui/nav.js railFoot()) ----
     The free part of the column is a size container. By its content height: the live plate (what you
     earn a day, miners online) from 106 px; + the rat asleep on its cheese from 152 px; + the lantern
     on a chain that runs up to the buttons from 280 px. Below 106 px nothing shows, so it never covers
     the buttons (short windows scroll the column as before). */
  .nav.is-rail { display: flex; flex-direction: column; }
  .nav.is-rail > .nav-track { flex: none; padding-bottom: 8px; }
  .rail-foot {
    flex: 1 1 0;
    min-height: 0;
    container: railfoot / size;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 0 0 14px;
    overflow: hidden;
  }
  .rail-deco {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
  }
  /* the chain: one 12 px period of the image's own chain, repeated up to a little hook */
  .rail-chain {
    display: none;
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    width: 12px;
    margin-top: 6px;
    transform: translateX(-2px); /* the image's chain is 2 px left of its centre */
    background-repeat: repeat-y;
    background-position: 0 100%;
    background-size: 12px 12px;
    image-rendering: pixelated;
  }
  .rail-chain::before { /* the hook it hangs from */
    content: '';
    position: absolute;
    top: -6px;
    left: -5px;
    width: 22px;
    height: 6px;
    background: var(--rail-edge);
    box-shadow: inset 0 2px 0 #5A4A99, 0 2px 0 var(--ink);
  }
  .rail-deco-art {
    flex: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 64px;
    height: 52px; /* only the rat on its cheese (rows 108-159) */
    margin-bottom: -6px; /* the cheese's shadow rests on the plate */
    overflow: hidden;
  }
  .rail-deco-art > .rr-sprite { flex: none; }

  .rail-plate {
    position: relative;
    z-index: 1;
    display: none;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 82px; /* iteration 34: «Al día» has 8 decimals (0,23961739) */
    padding: 7px 2px 6px;
    color: var(--text);
    font: inherit;
    text-align: center;
    background: #120C26;
    border: 2px solid var(--rail-edge);
    border-radius: 12px;
    box-shadow: 0 4px 0 var(--rail-drop), inset 0 2px 0 rgba(255, 255, 255, 0.05);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--t-fast) steps(2), transform 70ms steps(2);
  }
  .rail-plate:hover { background: #1C1438; }
  .rail-plate:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--rail-drop), inset 0 2px 0 rgba(255, 255, 255, 0.05); }
  .rail-plate:focus-visible { outline-offset: 2px; }
  .rail-day,
  .rail-miners { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
  .rail-miners { padding-top: 6px; border-top: 2px dashed #34295E; }
  .rail-cap {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.1;
    color: var(--text-2);
    white-space: nowrap;
  }
  .rail-day-num,
  .rail-miners-row {
    font: var(--px-s)/1 var(--f-display);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .rail-day-num { color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
  .rail-miners-row { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
  .rail-miners-row .rat-head { flex: none; margin-top: -2px; }
  /* a block just paid: the coin hops and the figure glints */
  .rail-plate.is-paid .rail-cap .rr-sprite { animation: rail-hop 800ms steps(8) both; }
  .rail-plate.is-paid .rail-day-num { animation: rail-glint 900ms steps(3) both; }
  @keyframes rail-hop {
    0% { transform: none; }
    25% { transform: translateY(-6px); }
    50% { transform: none; }
    65% { transform: translateY(-2px); }
    80%, 100% { transform: none; }
  }
  @keyframes rail-glint { 0%, 40% { color: var(--gold-hi); } 100% { color: var(--gold); } }

  @container railfoot (min-height: 106px) {
    .rail-plate { display: flex; }
  }
  @container railfoot (min-height: 152px) {
    .rail-deco { display: flex; }
  }
  @container railfoot (min-height: 280px) {
    .rail-chain { display: block; }
    .rail-deco-art { height: 160px; }
  }
}

@media (min-width: 1400px) {
  :root,
  body[data-route="guarida"] { --shell: 1840px; }
}

/* 640–1023 px: brand + player, then the chips (no tab row) */
@media (min-width: 640px) and (max-width: 1023.98px) {
  .hud-inner {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand player player settings"
      "qso qso power block";
  }
}

/* short screens: a tighter column (it scrolls if it still doesn't fit; the tags then only show
   inside the column, which is fine as a last resort) */
@media (min-width: 640px) and (max-height: 699.98px) {
  .nav { overflow-y: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-track { padding: 10px 0 12px; }
  .nav-list { gap: 8px; }
  .nav-link { width: 54px; height: 54px; border-radius: 12px; }
}

/* phones: the bottom dock with the same gray buttons (icon + short name) */
@media (max-width: 639.98px) {
  :root { --dock-h: 80px; }
  .nav-track {
    background: var(--rail-bg);
    box-shadow: inset 0 2px 0 #2A2148, 0 -3px 0 var(--ink);
  }
  .nav-list { gap: 4px; }
  .nav-link {
    min-height: 60px;
    color: var(--text-2);
    background: var(--rail-btn);
    border: 2px solid var(--rail-edge);
    border-radius: 12px;
    box-shadow: 0 3px 0 var(--rail-drop), inset 0 2px 0 rgba(255, 255, 255, 0.06);
  }
  .nav-link:hover { background: var(--rail-btn-hi); }
  .nav-link[aria-current="page"] {
    color: #FFFFFF;
    background: var(--rail-on);
    border-color: var(--rail-on-edge);
    box-shadow: 0 3px 0 var(--rail-on-drop), inset 0 2px 0 rgba(255, 255, 255, 0.1);
    transform: none;
  }
  .nav-link[aria-current="page"]:hover { background: var(--violet-face-hi); }
  .nav-icon { width: 32px; height: 32px; }
  .nav-icon .rr-sprite { opacity: 1; }
}

html[data-reduced-motion="true"] .nav-link:active,
html[data-reduced-motion="true"] .rail-plate:active { transform: none; }
html[data-reduced-motion="true"] .rail-plate * { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .rail-plate * { animation: none !important; }
}
/* the phone dock never shows the column's extras */
@media (max-width: 639.98px) {
  .rail-foot { display: none; }
}
