/* Atay — system states: loading, offline, error.
   Self-contained (only needs tokens.css) so it works on every page. */

/* ---------- Tea-glass illustration, shared by all states ---------- */

.st-glass { display: block; width: 64px; height: auto; overflow: visible; }
.st-glass--lg { width: 120px; }
.st-glass--md { width: 96px; }
.st-glass .tea { transform: translateY(0); }
.st-glass .steam path { opacity: 0; }

/* loading: the glass fills and empties, steam rises */
.st-glass.is-pouring .tea { animation: st-pour 1.8s cubic-bezier(.45, 0, .55, 1) infinite alternate; }
.st-glass.is-pouring .steam path { animation: st-steam 1.8s ease-in-out infinite; }
.st-glass.is-pouring .steam path:nth-child(2) { animation-delay: .5s; }
@keyframes st-pour { from { transform: translateY(30px); } to { transform: translateY(2px); } }
@keyframes st-steam {
  0% { opacity: 0; transform: translateY(4px); }
  40% { opacity: .8; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* offline: the signal arcs blink softly */
.st-glass .signal path { animation: st-blink 2.4s ease-in-out infinite; }
.st-glass .signal path:nth-child(2) { animation-delay: .3s; }
@keyframes st-blink { 50% { opacity: .25; } }

/* error: the glass wobbles once when the screen appears */
.st-glass.is-tipped .glass-body { transform-origin: 60px 104px; animation: st-tip .9s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes st-tip { from { transform: rotate(0); } to { transform: rotate(-18deg); } }

/* ---------- Full-screen state layout ---------- */

.st-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
  background: var(--surface-base); color: var(--ink);
  font-family: var(--sans); font-feature-settings: "lnum" 1;
}
.st-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.st-art {
  width: 164px; height: 164px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-raised); box-shadow: var(--shadow-2);
}
.st-eyebrow {
  margin: 0; font-size: var(--fs-label); font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
}
.st-title {
  margin: 0; font-family: var(--serif); font-size: var(--fs-title); font-weight: 600;
  line-height: 1.1; letter-spacing: -.01em; color: var(--ink); text-wrap: balance;
}
.st-text { margin: 0; max-width: 36ch; font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2); }
.st-note { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.st-actions { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }

.st-btn {
  appearance: none; box-sizing: border-box; border: 0; margin: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 0 22px; border-radius: 16px;
  background: var(--green); color: var(--cream); box-shadow: var(--shadow-cta);
  font-family: var(--sans); font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .15s var(--ease), background-color .15s;
}
@media (hover: hover) { .st-btn:hover { background: #10483F; } }
.st-btn:active { transform: scale(.98); }
.st-link {
  appearance: none; border: 0; margin: 0; background: none;
  padding: 10px 14px; min-height: 44px; border-radius: 10px;
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink-2);
  text-decoration: none; cursor: pointer; display: inline-flex; align-items: center;
  transition: background-color .15s, color .15s;
}
@media (hover: hover) { .st-link:hover { background: var(--green-tint); color: var(--green); } }
.st-btn:focus-visible, .st-link:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

.st-status { min-height: 20px; margin: -8px 0 0; font-size: var(--fs-small); color: var(--ink-3); }

@keyframes st-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.st-shake { animation: st-shake .35s ease; }

/* ---------- Overlays injected by shared/states.js ---------- */

.st-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.st-overlay.is-visible { opacity: 1; visibility: visible; transition: opacity .25s ease; }

.st-overlay--loading { background: rgba(246, 238, 223, .86); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.st-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.st-loading-label { font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }

.st-overlay--offline { background: var(--surface-base); overflow-y: auto; }
.st-overlay--offline .st-screen { min-height: 100%; background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .st-glass *, .st-overlay, .st-shake { animation: none !important; transition: none !important; }
  .st-glass.is-pouring .tea { transform: translateY(12px); }
  .st-glass.is-pouring .steam path { opacity: .6; }
}
