/* =========================================================
   Server rail (V2-RAIL): the windows beside every page, their sheet on smaller screens, and the
   home digest. The window frame, title bar, facts, counter, meter, top list, timetable and u-list
   come from css/components/window.css and data.css; this file sets the rail's density and its own parts.
   1180 px and up: a column (html.rail-right from js/rail.config.js), part of the page scroll. It has no
   scroller of its own; .is-sticky (js/rail.js, only on inner pages and only when it fits) pins it
   under the masthead. Below 1180 px: hidden; the server chip and the home digest open it as a sheet.
   ========================================================= */

.rail-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 0.85rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
  background: var(--ink-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.rail-chip:hover { border-color: var(--accent); background: var(--tint); }
.rail-chip .status-dot { width: 8px; height: 8px; }
@media (max-width: 420px) { .rail-chip { padding: 0 0.7rem; } }


/* ---------- Windows in the rail ---------- */
.rail { display: none; }
.rail-box[hidden], .rail .aside[hidden] { display: none; }
.rail-box .window-head { padding-block: 9px; }
.rail-box .window-body { padding: var(--s-3) var(--s-4) var(--s-4); font-size: var(--fs-sm); color: var(--text-2); }
.rail-box .window-body > * + *:not(.meter) { margin-top: var(--s-3); }
.rail-box .window-body > .meter-cap { margin-top: 0; }
.rail-box .window-body > .facts:first-child,
.rail-box .window-body > .timetable:first-child,
.rail-box .window-body > .u-list:first-child,
.rail-box .window-body > .top-list:first-child { margin-top: -6px; margin-bottom: -6px; }
.rail-box .skel { margin: 0.5rem 0; }
.rail-box .facts > div { padding: 7px 0; }
.rail-box .state { font-size: var(--fs-xs); }
.rail-box .state .status-dot, .rail-digest .state .status-dot { width: 7px; height: 7px; }

/* Server: the numeral, the brass meter, the facts under a hairline. */
.rail-w-status .counter b { font-size: clamp(2.25rem, 1.9rem + 0.6vw, 2.625rem); }
.rail-w-status .facts { padding-top: var(--s-1); border-top: 1px solid var(--line-soft); }
.rail-state { display: flex; align-items: center; gap: var(--s-2); color: var(--text); font-size: var(--fs-base); }
.rail-meta { color: var(--text-2); font-variant-numeric: tabular-nums; }
.rail-quiet { color: var(--text-2); }

.rail-event { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); color: var(--text); }
.rail-box .chip { font-size: 0.72rem; padding: 0.05rem 0.5rem; white-space: nowrap; }
.rail-box .timetable span { font-weight: 600; }
.rail-box .u-list .sub { line-height: 1.35; }
.rail-box .top-list .nm small { margin-top: 1px; }
.rail-w-guilds .top-list .lv { font-weight: 600; font-size: var(--fs-xs); letter-spacing: 0.02em; }

.rail-more, .rail-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
  text-underline-offset: 0.2em;
}
.rail-more:hover, .rail-link:hover { text-decoration-color: currentColor; }
.rail-more .icon, .rail-link .icon { width: 0.95em; height: 0.95em; color: var(--accent); }
.rail-w-community .window-body { display: grid; }
.rail-w-community .window-body > * + * { margin-top: 0; }
.rail-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-3); margin: -4px 0; }
.rail-links a { display: flex; align-items: center; min-height: 36px; color: var(--text); text-decoration: none; }
.rail-links a:hover, .rail-links a[aria-current="page"] { color: var(--accent-hi); text-decoration: underline; }

/* ---------- Account: the sign-in form ---------- */
.rail-w-account .window-body { padding-top: var(--s-4); }
.rail-form .form-field { margin-bottom: var(--s-3); }
.rail-form .form-field > label { margin-bottom: 6px; }
.rail-form .form-field input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; padding-block: 0.5em; }
.rail-form .pw-toggle { min-height: 0; }
.rail-form .btn-primary { margin-top: var(--s-2); }
.rail-form .form-submit-status { margin-top: var(--s-3); font-size: var(--fs-sm); }
.rail-form-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--s-3); margin: var(--s-2) 0 calc(-1 * var(--s-2)); }
.rail-form-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
  text-underline-offset: 0.2em;
}
.rail-form-links a:hover { text-decoration-color: currentColor; }

/* Signed in: the medallion, name and Silk, the characters, two plates. */
.rail-me { display: flex; align-items: center; gap: 14px; padding-left: 4px; }
.rail-me .medal { --m: 46px; }
.rail-me-text { min-width: 0; }
.rail-me-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.0625rem; font-weight: 700; color: var(--text); }
.rail-me-silk { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rail-me-silk .icon { width: 15px; height: 15px; color: var(--accent); }
.rail-me-silk b { color: var(--accent-hi); font-weight: 700; }
.rail-me-chars { font-size: var(--fs-xs); line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
.rail-me-chars span { color: var(--text-2); }
.rail-me-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.rail-me-actions .btn { min-height: 44px; padding-inline: var(--s-2); }
/* The masthead carries Download from 1240 px; below that the rail does (column and sheet). */
@media (min-width: 1240px) { .rail .rail-dl { display: none; } }

.rail-sheet-head { display: none; }

/* ---------- Desktop: the column ---------- */
@media (min-width: 1180px) {
  .rail-chip { display: none; }
  .rail-backdrop { display: none !important; }
  /* The page grid that places the rail lives in css/base.css (V2-SHELL). No max-height, no overflow:
     the rail is part of the page scroll, so the wheel over it moves the page. */
  .rail {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
    margin-block: var(--s-6);
  }
  .rail.is-sticky { position: sticky; top: calc(var(--head-h) + var(--s-4)); }
}

/* ---------- Below 1180 px: a sheet ---------- */
@media (max-width: 1179px) {
  .rail.is-open {
    position: fixed;
    z-index: calc(var(--z-menu) + 10);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    max-height: 86vh;
    max-height: 86dvh;
    overflow-y: auto;
    padding: var(--s-4) var(--gutter) calc(var(--s-6) + env(safe-area-inset-bottom, 0px));
    background: var(--ink-0);
    border-top: 1px solid var(--line-strong);
    border-radius: var(--r-4) var(--r-4) 0 0;
    box-shadow: var(--edge), var(--e-3);
    transition: transform 320ms var(--ease-out), opacity 320ms var(--ease-out);
  }
  @starting-style { .rail.is-open { transform: translateY(32px); opacity: 0; } }
  .rail.is-open .rail-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-1); }
  .rail.is-open > .window { flex: none; }
  .rail-sheet-title { font-size: var(--fs-xl); }
  .rail-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-menu) + 5);
    background: color-mix(in srgb, var(--ink-00) 72%, transparent);
  }
  html.rail-open { overflow: hidden; }
}
/* Tablets: a side panel on the rail's side. */
@media (min-width: 700px) and (max-width: 1179px) {
  .rail.is-open {
    top: 0;
    left: 0;
    right: auto;
    width: min(400px, 92vw);
    max-height: none;
    border-top: 0;
    border-right: 1px solid var(--line-strong);
    border-radius: 0 var(--r-4) var(--r-4) 0;
    padding-top: var(--s-5);
  }
  html.rail-right .rail.is-open { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--line-strong); border-radius: var(--r-4) 0 0 var(--r-4); }
  @starting-style { .rail.is-open { transform: translateX(24px); opacity: 0; } }
}

/* ---------- Home digest (phones and tablets; js/rail.js renderDigest) ---------- */
.rail-digest .window-body { padding: var(--s-3) var(--s-4) var(--s-4); }
.rail-digest-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--s-3) var(--s-5); }
.rail-digest .counter { flex-wrap: nowrap; }
.rail-digest .meter-cap { margin-top: 2px; }
.rail-digest .facts > div { padding: 5px 0; }
.rail-digest .meter { margin-top: var(--s-3); }
.rail-digest-off { color: var(--text); font-weight: 600; }
.rail-digest .rail-quiet + .btn { margin-top: var(--s-3); }
.rail-digest-more { margin-top: var(--s-4); }
.rail-digest-more .icon { color: var(--accent); }
@media (max-width: 359px) { .rail-digest-row { grid-template-columns: 1fr; } }
@media (min-width: 1180px) { .rail-digest { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .rail.is-open { transition: none; }
}
