/* Delivery bundle for the first paint shell.
   Sources of truth remain reset.css + tokens.css + design-system.css. */

@layer reset, tokens, base, layout, components, utilities, overrides;

@import "./reset.css";
@import "./tokens.css";

@layer base {
  body {
    font-family:
      "Manrope", "Manrope Fallback", -apple-system, BlinkMacSystemFont,
      "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg-light);
    -webkit-tap-highlight-color: transparent;
  }

  .app-shell-page {
    color: var(--color-text-default);
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100dvh;
    flex-direction: column;
    overflow: hidden;
  }
}

@layer layout {
  .app-shell-header {
    position: sticky;
    top: 0;
    z-index: var(--z-shell-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--shell-header-padding-y) var(--space-4);
    padding-top: calc(
      var(--shell-header-padding-y) + env(safe-area-inset-top, 0px)
    );
    background: var(--fftri-blue);
    color: var(--color-white);
    box-shadow: var(--shadow-soft);
  }

  .app-shell-header__brand,
  .app-shell-header__actions,
  .app-shell-bottom-nav {
    display: flex;
    align-items: center;
  }

  .app-shell-header__brand {
    min-width: 0;
    gap: var(--space-2);
  }

  .app-shell-header__actions {
    gap: var(--space-4);
  }

  .app-shell-main {
    position: relative;
    z-index: var(--z-index-shell-main);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    isolation: isolate;
    padding-bottom: calc(
      var(--shell-main-nav-offset) + env(safe-area-inset-bottom, 0px)
    );
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .app-shell-main::-webkit-scrollbar {
    display: none;
  }

  .app-shell-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-shell-bottom-nav);
    justify-content: space-around;
    width: 100%;
    padding-top: var(--shell-bottom-nav-padding-y);
    padding-bottom: calc(
      var(--shell-bottom-nav-padding-y) + env(safe-area-inset-bottom, 0px)
    );
    background: var(--color-bg-surface);
    border-top: 1px solid var(--color-border-soft);
    box-shadow: 0 -4px 6px -1px var(--overlay-dark-05);
  }

  .app-shell-bottom-nav[data-hidden="true"],
  #bottom-nav[data-hidden="true"] {
    display: none;
  }

  #bottom-nav {
    min-height: calc(
      var(--shell-bottom-nav-min-height) + env(safe-area-inset-bottom)
    );
  }
}

@layer components {
  .app-shell-skip-link {
    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-skip-link:focus {
    position: absolute;
    top: var(--shell-skip-link-offset);
    left: var(--shell-skip-link-offset);
    z-index: var(--z-skip-link);
    width: auto;
    height: auto;
    margin: 0;
    padding: var(--space-2) var(--space-3);
    overflow: visible;
    clip: auto;
    white-space: normal;
    border-radius: var(--radius-lg);
    background: var(--color-bg-surface);
    color: var(--fftri-blue);
  }

  .app-shell-header__logo {
    inline-size: var(--shell-logo-size);
    block-size: var(--shell-logo-size);
    flex-shrink: 0;
  }

  .app-shell-header__logo-image {
    width: 100%;
    height: 100%;
  }

  .app-shell-header__title {
    color: var(--color-white);
    font-size: var(--font-size-lg);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
  }

  .app-shell-header__title-dot {
    color: var(--fftri-red);
  }

  .app-shell-header__install,
  .app-shell-header__notif,
  .app-shell-header__user-slot-btn {
    min-width: var(--shell-icon-button-size);
    min-height: var(--shell-icon-button-size);
  }

  .app-shell-header__install {
    display: none;
    align-items: center;
    gap: var(--space-1-5);
    padding: var(--space-1-5) var(--space-2-5);
    border: 1px solid var(--overlay-white-35);
    border-radius: var(--radius-full);
    background: var(--overlay-white-15);
    color: var(--color-white);
    font-size: var(--font-size-xs);
    font-weight: 600;
    transition:
      background var(--duration-fast) ease,
      transform var(--duration-fast) ease;
  }

  .app-shell-header__install:hover {
    background: var(--overlay-white-25);
  }

  .app-shell-header__install:active {
    transform: scale(0.98);
  }

  .app-shell-header__install.is-visible {
    display: inline-flex;
  }

  .app-shell-header__install-icon {
    font-size: var(--font-size-11);
  }

  .app-shell-header__notif,
  .app-shell-header__user-slot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .app-shell-header__notif {
    position: relative;
    border: 0;
    background-color: transparent;
    color: var(--overlay-white-80);
    transition: color var(--duration-fast) ease;
  }

  .app-shell-header__notif:hover {
    color: var(--color-white);
  }

  .app-shell-header__notif-icon {
    font-size: var(--font-size-xl);
  }

  .app-shell-header__notif-badge {
    position: absolute;
    top: calc(var(--sp-0-5) * -1);
    right: calc(var(--sp-0-5) * -1);
    display: none;
    width: var(--shell-badge-size);
    height: var(--shell-badge-size);
    border: 2px solid var(--fftri-blue);
    border-radius: var(--radius-full);
    background: var(--fftri-red);
  }

  .app-shell-header__notif-badge.is-visible {
    display: block;
  }

  .app-shell-header__user-slot-btn {
    overflow: hidden;
  }

  .app-shell-header__user-slot-btn--guest {
    color: var(--color-white);
  }

  .app-shell-header__user-slot-fallback-icon {
    font-size: var(--font-size-xs);
  }

  .app-shell-header__user-slot-guest-icon {
    font-size: var(--font-size-sm);
  }

  :root[data-tab-accent="events"] {
    --tab-accent-current: var(--tab-accent-events);
  }

  :root[data-tab-accent="fftri"] {
    --tab-accent-current: var(--tab-accent-fftri);
  }

  :root[data-tab-accent="competition"] {
    --tab-accent-current: var(--tab-accent-competition);
  }

  :root[data-tab-accent="results"] {
    --tab-accent-current: var(--tab-accent-results);
  }

  :root[data-tab-accent="challenges"] {
    --tab-accent-current: var(--tab-accent-challenges);
  }

  :root[data-tab-accent="athletes"] {
    --tab-accent-current: var(--tab-accent-athletes);
  }

  :root[data-tab-accent="community"] {
    --tab-accent-current: var(--tab-accent-community);
  }

  :root[data-tab-accent="clubs"] {
    --tab-accent-current: var(--tab-accent-clubs);
  }

  :root[data-tab-accent="account"] {
    --tab-accent-current: var(--tab-accent-account);
  }

  .app-shell-bottom-nav__item {
    flex: 1;
    display: flex;
    min-height: var(--tap-target);
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    transition: transform var(--duration-fast) ease;
  }

  .app-shell-bottom-nav__item:active {
    transform: scale(0.95);
  }

  .app-shell-bottom-nav__icon {
    margin-bottom: var(--sp-0-5);
    font-size: var(--font-size-xl);
  }

  .app-shell-bottom-nav__label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    letter-spacing: -0.01em;
  }

  .nav-item {
    position: relative;
    min-width: 0;
    padding-bottom: var(--space-1-5);
  }

  .nav-item i {
    color: var(--color-contrast-low);
    transition:
      color var(--duration-normal) ease,
      transform var(--duration-fast) ease;
  }

  .nav-item span {
    display: block;
    overflow: hidden;
    color: var(--color-contrast-low);
    line-height: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: color var(--duration-normal) ease;
  }

  .nav-item::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 1px;
    width: var(--shell-nav-indicator-width);
    height: var(--shell-nav-indicator-height);
    border-radius: var(--radius-pill);
    background: var(--tab-accent-current);
    opacity: 0;
    transform: translateX(-50%) scaleX(0.2);
    transition:
      background var(--duration-normal) ease,
      transform var(--duration-fast) ease,
      opacity var(--duration-fast) ease;
  }

  .nav-item[aria-current="page"]::after {
    opacity: 1;
    transform: translateX(-50%) scaleX(1);
  }

  .nav-item[aria-current="page"] i {
    color: var(--tab-accent-current);
    transform: translateY(-1px);
  }

  .nav-item[aria-current="page"] span {
    color: var(--tab-accent-current);
    font-weight: 700;
  }

  #bottom-nav .nav-item:active {
    transform: none;
  }

  .fftri-back-to-top {
    position: fixed;
    right: var(--space-4);
    bottom: calc(
      var(--shell-back-to-top-offset) + env(safe-area-inset-bottom)
    );
    z-index: var(--z-back-to-top);
    display: inline-flex;
    width: var(--back-to-top-size);
    height: var(--back-to-top-size);
    align-items: center;
    justify-content: center;
    border: 1px solid var(--overlay-white-40);
    border-radius: var(--radius-pill);
    background: var(--fftri-blue);
    color: var(--color-white);
    box-shadow: 0 10px 24px var(--overlay-ink-24);
    opacity: 0;
    pointer-events: none;
    transform: translateY(var(--space-3)) scale(0.96);
    transition:
      opacity var(--duration-normal) ease,
      transform var(--duration-normal) ease,
      background-color var(--duration-normal) ease;
  }

  .fftri-back-to-top:hover {
    background: var(--fftri-teal);
  }

  .fftri-back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
}
