/* ReSurge Academy base: reset, type roles, browser surfaces, app shell. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
  background: var(--bg);
}

body {
  margin: 0;
  overflow-x: clip;
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  font-weight: var(--fw-regular);
  line-height: var(--lh-ui);
  letter-spacing: var(--tr-body);
  color: var(--ink);
  background: var(--bg);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection-bg); color: var(--selection-ink); }
input, textarea, select { caret-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

:focus-visible { outline: none; box-shadow: var(--ring); }
:focus:not(:focus-visible) { outline: none; }

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: not-allowed; }

img, svg { display: block; max-width: 100%; }

a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }

h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ---------- type roles ---------- */
h1, h2, h3, h4 { font-weight: var(--fw-bold); }
h1 {
  font-size: var(--fs-30); line-height: var(--lh-heading); letter-spacing: var(--tr-h1);
  text-wrap: balance;
}
h2 { font-size: var(--fs-24); line-height: var(--lh-heading); letter-spacing: var(--tr-h2); text-wrap: balance; }
h3 { font-size: var(--fs-20); line-height: 1.25; letter-spacing: var(--tr-h3); font-weight: var(--fw-semi); text-wrap: balance; }
h4 { font-size: var(--fs-16); line-height: 1.35; letter-spacing: 0; font-weight: var(--fw-semi); }
h1:focus, [tabindex="-1"]:focus { outline: none; }

.t-display {
  font-size: var(--fs-40); font-weight: var(--fw-bold); line-height: var(--lh-display);
  letter-spacing: var(--tr-display); text-wrap: balance;
}
.t-small { font-size: var(--fs-14); line-height: var(--lh-ui); color: var(--ink-2); }
.t-meta { font-size: var(--fs-13); font-weight: var(--fw-medium); line-height: 1.4; color: var(--ink-3); }
.num {
  font-family: var(--font-mono); font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums slashed-zero;
}
strong, b { font-weight: var(--fw-semi); }

th {
  font-size: var(--fs-13); font-weight: var(--fw-semi); line-height: 1.3;
  letter-spacing: var(--tr-label); text-transform: uppercase; color: var(--ink-2); text-align: left;
}

@media (min-width: 1024px) {
  h1 { font-size: var(--fs-40); }
  .t-display { font-size: var(--fs-56); }
}

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* scroll containers get the thin scrollbar, the page does not */
.table-wrap, .ask-thread, .deck-strip, .scroll { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }

/* ---------- skip link ---------- */
.skip {
  position: fixed; left: var(--sp-4); top: var(--sp-2); z-index: calc(var(--z-toast) + 10);
  padding: 10px 16px; border-radius: var(--r-3);
  background: var(--brand); color: var(--on-brand); font-weight: var(--fw-semi); text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur-2) var(--ease-out);
}
.skip:focus { transform: translateY(0); }

/* ---------- boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: var(--z-toast);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-6);
  background: var(--bg);
}
.boot__lockup { display: flex; align-items: center; gap: 16px; }
.boot__lockup img { height: 72px; width: auto; }

/* ---------- logo lockup ---------- */
.logo { display: inline-flex; align-items: center; gap: 16px; text-decoration: none; color: var(--ink); min-height: var(--tap); }
.logo:hover { color: var(--ink); }
.logo__img { height: 46px; width: auto; flex: none; }
.logo--lg .logo__img { height: 92px; }
.logo__rule { width: 1px; height: 24px; background: var(--line); flex: none; }
.logo__word { font-size: 18px; font-weight: var(--fw-semi); color: var(--ink-2); line-height: 1; }
.logo--on-deep .logo__rule { background: var(--deep-line); }
.logo--on-deep .logo__word { color: var(--on-deep-2); }
.logo--on-deep { color: var(--on-deep); }
.logo--compact .logo__rule, .logo--compact .logo__word { display: none; }
@media (max-width: 479px) {
  .logo__rule, .logo__word { display: none; }
}

/* ---------- app shell ---------- */
#app { min-height: 100vh; min-height: 100dvh; }
#view { outline: none; }
#view > * { max-width: var(--page-max); }

.banner-offline {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: var(--warn-tint); color: var(--ink); border-bottom: 1px solid var(--line);
  font-size: var(--fs-14);
}
.banner-offline .icon { color: var(--warn); flex: none; }

/* phone and tablet (below 1024px) */
#rail { display: none; }

#topbar {
  position: sticky; top: 0; z-index: var(--z-bar);
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-2) 0 var(--sp-4);
}
.topbar__spacer { flex: 1; }
.topbar__streak {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); padding: 0 8px;
  font-family: var(--font-mono); font-weight: var(--fw-semi); font-size: var(--fs-14);
  font-variant-numeric: tabular-nums slashed-zero; color: var(--ink);
}
.topbar__streak .icon { color: var(--brand-ink); width: 18px; height: 18px; }

.topbtn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border-radius: var(--r-3); color: var(--ink-2);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.topbtn:hover { background: var(--bg-tint-2); color: var(--ink); }
.topbtn .badge { position: absolute; top: 4px; right: 2px; }

.focusbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-2);
}
.focusbar__back {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  border-radius: var(--r-3); color: var(--ink); text-decoration: none;
}
.focusbar__back:hover { background: var(--bg-tint-2); color: var(--ink); }
.focusbar__title {
  flex: 1; font-size: var(--fs-16); font-weight: var(--fw-semi); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-bar);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar { height: var(--tabbar-h); display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar__item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap); color: var(--ink-3); font-size: var(--fs-13); font-weight: var(--fw-medium);
  text-decoration: none; text-align: center;
  transition: color var(--dur-1) var(--ease-out);
}
.tabbar__item:hover { color: var(--ink); }
.tabbar__item[aria-current="page"] { color: var(--brand-ink); font-weight: var(--fw-semi); }
.tabbar__item[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 24px; height: 2px; margin-left: -12px;
  background: var(--brand); border-radius: 0 0 2px 2px;
}

#view {
  padding: var(--sp-4);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-8));
  min-height: calc(100dvh - var(--topbar-h));
}
@media (min-width: 768px) {
  #view { padding: var(--sp-8); padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-8)); }
}

/* chrome modes on phone */
body[data-chrome="focus"] #tabbar { display: none; }
body[data-chrome="focus"] #view { padding-bottom: var(--sp-8); }
body[data-chrome="bare"] #topbar,
body[data-chrome="bare"] #tabbar,
body[data-chrome="bare"] #rail { display: none; }
body[data-chrome="bare"] #view { padding: 0; min-height: 100dvh; }
body[data-chrome="bare"] #view > * { max-width: none; }

/* desktop (1024px and up): the rail replaces top bar and tab bar */
@media (min-width: 1024px) {
  #app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); align-items: start; }
  #topbar, #tabbar { display: none; }
  #rail {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: var(--z-rail);
    background: var(--bg-tint); border-right: 1px solid var(--line);
    padding: var(--sp-5) var(--sp-3) var(--sp-4); overflow-y: auto;
  }
  #view { padding: var(--sp-10); min-height: 100dvh; }
  body[data-chrome="focus"] #view { padding-bottom: var(--sp-10); }
  body[data-chrome="bare"] #app { display: block; }
  body[data-chrome="bare"] #view { padding: 0; }
  #view > * { margin-left: 0; margin-right: auto; }
}

/* ---------- rail ---------- */
.rail__logo { padding: 0 var(--sp-2) var(--sp-6); }
.rail__nav { display: flex; flex-direction: column; gap: 2px; }
.rail__item {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding: 0 var(--sp-3); border-radius: var(--r-3);
  font-size: var(--fs-16); font-weight: var(--fw-medium); color: var(--ink-2); text-decoration: none;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.rail__item:hover { background: var(--bg-tint-2); color: var(--ink); }
.rail__item[aria-current="page"] { background: var(--bg-tint-2); color: var(--brand-ink); font-weight: var(--fw-semi); }
.rail__sep { height: 1px; background: var(--line); margin: var(--sp-3) var(--sp-3); }
.rail__spacer { flex: 1; min-height: var(--sp-6); }
.rail__foot { display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.rail__stat { display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-2); font-size: var(--fs-14); color: var(--ink-2); }
.rail__stat .icon { color: var(--brand-ink); width: 18px; height: 18px; }
.rail__stat .num { color: var(--ink); font-weight: var(--fw-semi); }
.rail__tools { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-1); }
.rail__user { display: inline-flex; border-radius: var(--r-round); }
.rail__user:hover .avatar { background: var(--line); }

/* ---------- notifications ---------- */
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.notif-panel__head h2 { font-size: var(--fs-20); }
.notif-list { display: flex; flex-direction: column; gap: 2px; max-height: min(60vh, 28rem); overflow-y: auto; scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.sheet .notif-list { max-height: none; }
.notif {
  position: relative; display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5); border-radius: var(--r-3);
  color: var(--ink); text-decoration: none; min-height: var(--tap); width: 100%;
}
a.notif:hover, button.notif:hover { background: var(--bg-tint); color: var(--ink); }
.notif.is-unread { background: var(--bg-tint); }
.notif.is-unread::before {
  content: ""; position: absolute; left: 8px; top: 20px; width: 8px; height: 8px; border-radius: var(--r-round); background: var(--brand);
}
.notif .icon { color: var(--brand-ink); flex: none; margin-top: 2px; }
.notif__body { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-14); }
.notif__text { color: var(--ink); line-height: 1.4; }
.notif-empty { padding: var(--sp-6) var(--sp-4); color: var(--ink-2); font-size: var(--fs-14); }

.account-menu__who { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-2); }
.account-menu__who strong { display: block; }
.account-menu__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: var(--tap); padding: 0 var(--sp-3); font-size: var(--fs-14); }
.account-menu__row--col { flex-direction: column; align-items: stretch; justify-content: center; padding-top: var(--sp-2); padding-bottom: var(--sp-2); gap: var(--sp-2); }
.account-menu__hr { height: 1px; background: var(--line); margin: var(--sp-2) 0; }

.more-sheet { display: flex; flex-direction: column; gap: var(--sp-2); }
.more-sheet__who { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-2); }

/* stubs and view-missing states */
.stub { padding: var(--sp-8) 0; }
.stub h1 { margin-bottom: var(--sp-3); }

/* logo swaps with the theme */
.logo__img--dark { display: none; }
:root[data-theme="dark"] .logo__img--light { display: none; }
:root[data-theme="dark"] .logo__img--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo__img--light { display: none; }
  :root:not([data-theme="light"]) .logo__img--dark { display: block; }
}

.notif-panel__head--flush { padding-left: 0; padding-right: 0; }
@media (min-width: 1024px) {
  #rail { grid-column: 1; grid-row: 1 / span 2; }
  #offline { grid-column: 2; grid-row: 1; }
  #view { grid-column: 2; grid-row: 2; }
  body[data-chrome="bare"] #offline { display: none; }
}
