/*
 * Shared phone "app shell" for tools.skyvora.id: bottom bar, tools sheet, toast, and — on tool
 * pages — a native-style app bar with a large title. Injected by shell.js; desktop is untouched.
 * Uses its own --shell-* tokens so it looks the same inside every tool.
 */

:root {
  --shell-text: #2f2b36;
  --shell-muted: #77727f;
  --shell-bg: #f7f6fb;
  --shell-surface: #ffffff;
  --shell-border: #e4e2e8;
  --shell-accent: #4f46e5;
  --shell-bar-height: 64px;
  --shell-compressor: #b45309;
  --shell-converter: #4f46e5;
  --shell-video: #0369a1;
  --shell-currency: #047857;
  --shell-numsystem: #0e7490;
  --shell-player: #4338ca;
}

@media (prefers-color-scheme: dark) {
  :root {
    --shell-text: #ece9f2;
    --shell-muted: #a09aab;
    --shell-bg: #131118;
    --shell-surface: #1c1922;
    --shell-border: #2e2a36;
    --shell-accent: #8b93fb;
    --shell-compressor: #f5a742;
    --shell-converter: #8b93fb;
    --shell-video: #38bdf8;
    --shell-currency: #34d399;
    --shell-numsystem: #22d3ee;
    --shell-player: #a5b4fc;
  }
}

.shell-appbar,
.shell-bar,
.shell-toast {
  display: none;
}

@media (max-width: 720px) {
  html.shell body {
    /* Room for the bottom bar and the home indicator. */
    padding-bottom: calc(var(--shell-bar-height) + 8px + env(safe-area-inset-bottom));
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Bottom bar ─────────────────────────────────────────────────────── */

  .shell-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--shell-surface) 86%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid color-mix(in srgb, var(--shell-border) 80%, transparent);
    font: 600 11px/1.2 system-ui, "Segoe UI", Roboto, sans-serif;
  }

  .shell-bar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    padding: 0;
    border: none;
    background: none;
    color: var(--shell-muted);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease-out;
  }

  .shell-bar__item:active {
    transform: scale(0.92);
  }

  .shell-bar__item:focus-visible {
    outline: 2px solid var(--shell-accent);
    outline-offset: -4px;
    border-radius: 14px;
  }

  .shell-bar__item svg {
    width: 56px;
    height: 28px;
    padding: 2px 16px;
    border-radius: 999px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Material-style pill behind the current tab. */
  .shell-bar__item--active {
    color: var(--shell-accent);
  }

  .shell-bar__item--active svg {
    background: color-mix(in srgb, var(--shell-accent) 15%, transparent);
  }

  /* ── App bar (tool pages) ───────────────────────────────────────────── */

  .shell-appbar {
    position: sticky;
    top: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0 4px;
    background: color-mix(in srgb, var(--shell-bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid transparent;
    color: var(--shell-text);
    font: 16px/1.3 system-ui, "Segoe UI", Roboto, sans-serif;
    transition: border-color 0.2s;
  }

  .shell-appbar__back {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 44px;
    padding: 0 8px 0 4px;
    border-radius: 12px;
    color: var(--shell-accent);
    font-weight: 500;
    text-decoration: none;
  }

  .shell-appbar__back:active {
    background: color-mix(in srgb, var(--shell-accent) 12%, transparent);
  }

  .shell-appbar__back svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* The small title appears once the page's large title scrolls away (iOS-style). */
  .shell-appbar__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    margin-right: 64px;
    font-size: 17px;
    font-weight: 700;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
  }

  .shell-appbar--scrolled {
    border-bottom-color: color-mix(in srgb, var(--shell-border) 80%, transparent);
  }

  .shell-appbar--scrolled .shell-appbar__title {
    opacity: 1;
    transform: none;
  }

  /* ── Tool pages: large title instead of the desktop hero ────────────── */

  /* Both, so short pages don't show a band of the app's own page colour below the content. */
  html.shell-tool,
  html.shell-tool body {
    background: var(--shell-bg);
  }

  html.shell-tool .page {
    padding-top: 4px;
  }

  html.shell-tool .header {
    margin-bottom: 18px;
    text-align: left;
  }

  /* The app bar's back button replaces these; the step guide and big art are desktop extras. */
  html.shell-tool .header__home,
  html.shell-tool .header .steps,
  html.shell-tool .header .steps-guide,
  html.shell-tool .hero__art {
    display: none;
  }

  html.shell-tool .hero {
    display: block;
    text-align: left;
  }

  html.shell-tool .hero h1 {
    margin: 0 0 4px;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.025em;
  }

  html.shell-tool .header__subtitle {
    margin: 0;
    font-size: 14px;
  }

  html.shell-tool .stats-badge {
    margin-top: 12px;
  }

  /* Tools with their own sticky action bar keep it just above the bottom bar. */
  html.shell .action-bar {
    bottom: calc(var(--shell-bar-height) + env(safe-area-inset-bottom));
  }

  /* ── Tools sheet ────────────────────────────────────────────────────── */

  .shell-sheet {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    border: none;
    border-radius: 24px 24px 0 0;
    background: var(--shell-surface);
    color: var(--shell-text);
    box-shadow: 0 -8px 40px rgb(0 0 0 / 20%);
    font: 16px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  }

  .shell-sheet[open] {
    animation: shell-sheet-up 0.25s ease-out;
  }

  .shell-sheet::backdrop {
    background: rgb(10 8 18 / 45%);
  }

  @keyframes shell-sheet-up {
    from {
      transform: translateY(100%);
    }
  }

  .shell-sheet__handle {
    width: 40px;
    height: 5px;
    margin: 0 auto 12px;
    border-radius: 999px;
    background: var(--shell-border);
  }

  .shell-sheet__title {
    margin: 0 4px 10px;
    font-size: 18px;
    font-weight: 700;
  }

  .shell-sheet__list {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .shell-sheet__item {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 8px;
    border-radius: 14px;
    color: inherit;
    text-decoration: none;
  }

  .shell-sheet__item:active,
  .shell-sheet__item[aria-current="page"] {
    background: var(--shell-bg);
  }

  .shell-sheet__item svg {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--tool) 14%, transparent);
    fill: none;
    stroke: var(--tool);
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .shell-sheet__text {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: var(--shell-muted);
  }

  .shell-sheet__text strong {
    font-size: 15px;
    color: var(--shell-text);
  }

  .shell-sheet__here {
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--shell-accent) 14%, transparent);
    color: var(--shell-accent);
    font-size: 11px;
    font-weight: 700;
  }

  .shell-sheet__close {
    width: 100%;
    min-height: 48px;
    margin-top: 10px;
    border: none;
    border-radius: 14px;
    background: var(--shell-bg);
    color: var(--shell-text);
    font: inherit;
    font-weight: 700;
  }

  .shell-toast:not([hidden]) {
    display: block;
    position: fixed;
    left: 50%;
    bottom: calc(var(--shell-bar-height) + 20px + env(safe-area-inset-bottom));
    z-index: 30;
    transform: translateX(-50%);
    margin: 0;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--shell-text);
    color: var(--shell-bg);
    font: 600 14px/1.3 system-ui, "Segoe UI", Roboto, sans-serif;
    white-space: nowrap;
  }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .shell-bar__item,
  .shell-appbar,
  .shell-appbar__title {
    transition: none;
  }

  .shell-bar__item:active {
    transform: none;
  }

  .shell-sheet[open] {
    animation: none;
  }
}
