/* ==========================================================================
   AshFall app (installable PWA at /app). Builds on style.css tokens.
   ========================================================================== */
.app {
  --bar-h: 56px;
  --tab-h: 62px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: calc(var(--bar-h) + var(--safe-t)); /* where the Halloween spider and webs hang from */
  background:
    radial-gradient(120% 50% at 50% 0%, rgba(122, 10, 28, .28), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100svh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* ---------- top bar ---------- */
.app-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--nav-h); padding: var(--safe-t) 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(7, 5, 6, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.app-bar .brand { font-size: 1.3rem; }
.app-pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 55%;
  padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 999px;
  background: rgba(255, 255, 255, .03); color: var(--text); cursor: pointer;
  font: 600 .68rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
}
.app-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- views ---------- */
.app-main {
  padding: calc(var(--nav-h) + 18px) 16px calc(var(--tab-h) + var(--safe-b) + 28px);
  max-width: 640px; margin: 0 auto;
}
.view { animation: view-in .28s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
.view-title { font-size: 2.2rem; margin: 6px 0 6px; }
.view-sub { margin-bottom: 18px; }
.app-h2 {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 28px 0 12px; font-size: 1rem; letter-spacing: .16em;
}
.app-h2 a { font: 600 .7rem/1 var(--f-mono); letter-spacing: .14em; color: var(--ember-2); text-decoration: none; }

.app-hero { margin: 4px 0 20px; }
.app-hero .eyebrow { margin-bottom: .9rem; font-size: .7rem; }
.app-hero .hero-title { font-size: clamp(2.4rem, 12vw, 3.6rem); }
.app-hero .hw-badge { font-size: 1.5rem; margin-bottom: .7rem; }

/* ---------- install card + iOS sheet ---------- */
.install-card {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center;
  margin-bottom: 18px; padding: 14px 40px 14px 14px;
  background: linear-gradient(135deg, rgba(220, 20, 60, .16), rgba(20, 16, 18, .9));
  border: 1px solid rgba(220, 20, 60, .45);
}
.install-card img { grid-row: span 2; border-radius: 12px; }
.install-card b { font: 600 1rem/1.2 var(--f-head); letter-spacing: .06em; text-transform: uppercase; }
.install-card p { font-size: .82rem; color: var(--muted); line-height: 1.4; }
.install-card .btn { grid-column: 2; justify-self: start; }
.install-x {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px;
  background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer;
}

.alert-card > svg {
  grid-row: span 2; width: 44px; height: 44px; padding: 9px;
  fill: none; stroke: var(--ember-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  border: 1px solid rgba(220, 20, 60, .45); border-radius: 12px;
  animation: ring-bell 3s ease-in-out infinite; transform-origin: 50% 20%;
}
@keyframes ring-bell { 0%, 80%, 100% { rotate: 0deg; } 84% { rotate: 12deg; } 88% { rotate: -10deg; } 92% { rotate: 6deg; } }

/* ---------- status card ---------- */
.status-card {
  position: relative; display: grid; grid-template-columns: 116px 1fr; gap: 16px; align-items: center;
  padding: 18px; background: var(--panel); border: 1px solid var(--line);
}
.status-card::before, .status-card::after {
  content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid var(--ember);
}
.status-card::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.status-card::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }
.status-ring { position: relative; width: 116px; aspect-ratio: 1; }
.status-ring svg { width: 100%; height: 100%; rotate: -90deg; }
.status-ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--line); }
.ring-fg {
  stroke: var(--ember); stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1s cubic-bezier(.2, .7, .2, 1), stroke .3s;
  filter: drop-shadow(0 0 6px rgba(220, 20, 60, .6));
}
.status-ring.live .ring-fg { stroke: var(--good); filter: drop-shadow(0 0 6px rgba(143, 209, 106, .5)); }
.status-ring.scanning .ring-fg { stroke-dashoffset: 250; animation: scan 1.4s linear infinite; transform-origin: 60px 60px; }
@keyframes scan { to { transform: rotate(360deg); } }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text b { font: 700 1.7rem/1 var(--f-head); }
.ring-text span { font: 600 .58rem/1.6 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.status-head { display: flex; align-items: center; gap: 8px; font: 600 .82rem/1.2 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
.status-grid dt { font: 600 .6rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.status-grid dd { margin: 4px 0 0; font: 600 .95rem/1.2 var(--f-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-note { margin-top: 10px; font-size: .8rem; color: var(--ember-2); line-height: 1.4; }
.status-time { margin-top: 10px; font: 400 .66rem/1 var(--f-mono); color: var(--muted); letter-spacing: .08em; }
.status-card .hud-copy { grid-column: 1 / -1; margin-top: 0; }

/* ---------- quick actions ---------- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.quick-btn {
  display: grid; justify-items: center; gap: 8px; padding: 14px 4px 12px;
  background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--text);
  font: 600 .66rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase;
  transition: border-color .2s, background .2s, transform .1s;
}
.quick-btn:active { transform: scale(.96); background: var(--panel-2); }
.quick-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ember-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#qDiscord svg { fill: #8b95ff; stroke: none; }

/* ---------- intel ---------- */
.intel-list { display: grid; gap: 12px; }
.intel {
  padding: 16px 16px 16px 18px; background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--ember);
}
.intel.tag-warning { border-left-color: var(--blood); }
.intel.tag-dev-log { border-left-color: var(--steel); }
.intel.tag-event { border-left-color: var(--ember-2); }
.intel .dispatch-meta { margin-bottom: 10px; }
.intel h3 { font-size: 1.15rem; margin-bottom: 6px; }
.intel p { color: var(--muted); font-size: .92rem; white-space: pre-line; }
.intel.clamp p { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.intel small { display: block; margin-top: 10px; font: 400 .68rem/1 var(--f-mono); color: var(--muted); }

.bench { display: grid; gap: 10px; }
.bench .wb-item { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: start; }
.bench .wb-item p { grid-column: 1 / -1; }
.bench .wb-item i { font: 600 .6rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; font-style: normal; padding: 4px 6px; border: 1px solid var(--line-2); color: var(--muted); }
.bench .wb-item i.in_progress { color: var(--ember-2); border-color: var(--ember); }

/* ---------- rules ---------- */
.app-search { margin: 14px 0 8px; }
.app-search input { width: 100%; }
.app-rules { margin-top: 10px; border-top: 1px solid var(--line); }
.app-sec { border-bottom: 1px solid var(--line); }
.app-sec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 16px 2px;
  font: 700 1.05rem/1.2 var(--f-head); letter-spacing: .05em; text-transform: uppercase;
}
.app-sec > summary::-webkit-details-marker { display: none; }
.app-sec > summary b { font: 600 .74rem/1 var(--f-mono); color: var(--ember); min-width: 22px; }
.app-sec > summary small { margin-left: auto; font: 400 .68rem/1 var(--f-mono); color: var(--muted); }
.app-sec > summary::after { content: '+'; font: 400 1.3rem/1 var(--f-mono); color: var(--muted); transition: rotate .2s; }
.app-sec[open] > summary::after { rotate: 45deg; color: var(--ember); }
.app-sec-body { padding: 0 2px 10px; }
.app-sec-body .rule { padding: 18px 0; }
.app-sec-body .rule:last-child { border-bottom: 0; }
.app-sec-body .rule h3 { font-size: 1.02rem; gap: 10px; }
.app-sec-body .rule ul.cols { grid-template-columns: 1fr; }
.app-sec-body .raid-table { width: 100%; min-width: 0; font-size: .8rem; }
.app-sec-body .raid-table th, .app-sec-body .raid-table td { padding: 8px 10px; }
.app-sec-body .channels div { grid-template-columns: 1fr; gap: 2px; }
.app-sec-body .ladder > .rule { padding-left: 0; }
.app-sec-body .ladder .lvl { position: static; display: inline-block; margin-bottom: 10px; }

/* ---------- me ---------- */
.me-card { padding: 22px 18px; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.me-card .avatar { width: 88px; height: 88px; margin: 0 auto 12px; border-radius: 50%; border: 2px solid var(--ember); box-shadow: 0 0 30px rgba(220, 20, 60, .35); }
.me-card h2 { font-size: 1.6rem; }
.me-card .muted { font: 400 .8rem/1.4 var(--f-mono); margin-top: 4px; }
.me-card .badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 14px; }
.me-state { margin-top: 14px; font: 600 .72rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--good); }
.me-state.warn { color: var(--ember-2); }
.me-intro { margin: 0 0 18px; color: #d4caca; }
.me-intro + .btn { margin-bottom: 10px; }
.me-list { margin-top: 18px; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.me-list a, .me-list button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 16px; background: var(--panel); border: 0; color: var(--text); text-decoration: none; cursor: pointer;
  font: 600 .86rem/1 var(--f-head); letter-spacing: .12em; text-transform: uppercase; text-align: left;
}
.me-list a::after { content: '›'; font: 400 1.3rem/1 var(--f-body); color: var(--muted); }
.me-list .danger { color: #ff6b7a; }
.me-foot { margin-top: 22px; text-align: center; font: 400 .7rem/1.6 var(--f-mono); color: var(--muted); }

.alerts-card { padding: 18px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 14px; }
.alerts-card > p { color: #d4caca; font-size: .9rem; line-height: 1.5; }
.alerts-card .btn-sm { justify-self: start; }
.alerts-state.on { color: var(--good) !important; font: 600 .74rem/1.4 var(--f-mono) !important; letter-spacing: .12em; text-transform: uppercase; }
.switches { display: grid; border-top: 1px solid var(--line); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch span { display: grid; gap: 3px; }
.switch b { font: 600 .9rem/1.2 var(--f-head); letter-spacing: .08em; text-transform: uppercase; }
.switch small { font-size: .78rem; color: var(--muted); }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 46px; height: 26px; margin: 0; padding: 0;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2); cursor: pointer; transition: background .2s, border-color .2s;
}
.switch input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: translate .2s, background .2s;
}
.switch input:checked { background: rgba(220, 20, 60, .3); border-color: var(--ember); }
.switch input:checked::after { translate: 20px 0; background: var(--ember-2); box-shadow: 0 0 10px rgba(220, 20, 60, .7); }
.switch input:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(7, 5, 6, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; display: grid; place-content: center; justify-items: center; gap: 5px;
  color: var(--muted); text-decoration: none;
  font: 600 .6rem/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  transition: color .2s;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.tabbar a.active { color: var(--text); }
.tabbar a.active svg { stroke: var(--ember-2); transform: translateY(-2px); filter: drop-shadow(0 0 6px rgba(220, 20, 60, .6)); }
.tabbar a.active::before {
  content: ''; position: absolute; top: -1px; left: 30%; right: 30%; height: 2px;
  background: var(--ember); box-shadow: 0 0 12px var(--ember);
}

/* ---------- pull to refresh ---------- */
.ptr {
  position: fixed; left: 50%; top: calc(var(--nav-h) + 6px); z-index: 49;
  width: 36px; height: 36px; margin-left: -18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line-2);
  opacity: 0; transform: translateY(-50px); pointer-events: none;
}
.ptr span { width: 16px; height: 16px; border: 2px solid var(--ember); border-right-color: transparent; border-radius: 50%; }
.ptr.spin span { animation: scan .7s linear infinite; }

/* the toast sits above the tab bar */
.app .toast { bottom: calc(var(--tab-h) + var(--safe-b) + 14px); }

/* standalone: no text selection on chrome, like a native app */
@media (display-mode: standalone) {
  .app-bar, .tabbar, .quick-btn { -webkit-user-select: none; user-select: none; }
}
@media (min-width: 700px) {
  .app-main { padding-left: 24px; padding-right: 24px; }
}
