/*
 * app_shell.css — Fixed viewport app shell
 * Grailsome Design System — Consumer-Grade Refactor
 */

/* -------------------------------------------------------
   Accessibility — visually-hidden utility (live region, etc.)
------------------------------------------------------- */

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

/* -------------------------------------------------------
   App Shell — locked viewport, no page scroll
------------------------------------------------------- */

html, body {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  margin: 0;
  padding: 0;
}

/* -------------------------------------------------------
   Header — semi-transparent, centered logo
------------------------------------------------------- */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(250, 246, 238, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(26, 13, 8, 0.08);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.app-header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transform-origin: center;
  will-change: transform;
}

.app-header__icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.app-header__wordmark {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 17px;
  color: var(--color-ink);
  letter-spacing: 0.02em;
  line-height: 1;
}

.app-header__wordmark-ai {
  color: var(--color-ink-muted);
}

.app-header__left,
.app-header__right {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-header__left {
  justify-content: flex-start;
}

.app-header__right {
  justify-content: flex-end;
}

.app-header__action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid rgba(26, 13, 8, 0.12);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
  transform-origin: center;
}

/* -------------------------------------------------------
   Workspace — scrollable content area
------------------------------------------------------- */

.app-workspace {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(64px + 16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  padding-top: 56px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.app-workspace::-webkit-scrollbar {
  display: none;
}

/* Inner container for workspace content */
.app-workspace__content {
  padding: var(--space-4);
  max-width: var(--max-content);
  margin-inline: auto;
}

/* -------------------------------------------------------
   Bottom Toolbar — iOS-style tab bar
------------------------------------------------------- */

.app-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + 16px + env(safe-area-inset-bottom, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: rgba(250, 246, 238, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(26, 13, 8, 0.08);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.app-toolbar__tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  padding: 6px 16px;
  min-width: 64px;
  min-height: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.app-toolbar__icon {
  flex-shrink: 0;
}

.app-toolbar__label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--color-ink-muted);
}

/* Inactive state (default) */
.app-toolbar__tab--inactive .app-toolbar__label {
  color: var(--color-ink-muted);
}

/* Active state */
.app-toolbar__tab--active .app-toolbar__label {
  color: var(--color-red);
  font-weight: 600;
}

/* -------------------------------------------------------
   Pull-to-refresh indicator
------------------------------------------------------- */

.pull-indicator {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-40px);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--color-ink-muted);
  border-top-color: var(--color-red);
  opacity: 0;
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
  z-index: 50;
}

.pull-indicator--visible {
  opacity: 1;
}

.pull-indicator--refreshing {
  animation: spin 600ms linear infinite;
}

.pull-indicator--ready {
  border-top-color: var(--color-red);
  border-color: var(--color-red);
  opacity: 1;
}

@keyframes spin {
  to { transform: translateX(-50%) translateY(0) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .pull-indicator--refreshing {
    animation: none;
    opacity: 0.6;
  }
}

/* -------------------------------------------------------
   PWA display-mode utilities (from Campfire)
------------------------------------------------------- */

.hide-in-pwa {
  @media (display-mode: standalone) {
    display: none !important;
  }
}

.hide-in-browser {
  @media (display-mode: browser) {
    display: none !important;
  }
}

.hide-in-ios-pwa {
  @media (display-mode: standalone) {
    @supports (-webkit-touch-callout: none) {
      display: none !important;
    }
  }
}
