/**
 * Ferom — базовые стили
 */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--md-ref-typeface-plain);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-background);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Material Symbols */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-rounded.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Mobile shell */
#app {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--md-sys-color-surface);
  overflow: hidden;
  box-shadow: var(--md-sys-elevation-1);
}

@media (min-width: 431px) {
  body {
    display: flex;
    justify-content: center;
  }
  #app {
    min-height: 100dvh;
    border-left: 1px solid var(--md-sys-color-outline-variant);
    border-right: 1px solid var(--md-sys-color-outline-variant);
  }
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Экраны — ТОЛЬКО active виден */
.screen {
  display: none !important;
  flex-direction: column;
  width: 100%;
  min-height: 100dvh;
  background: var(--md-sys-color-surface);
}

.screen.active {
  display: flex !important;
}

.screen--with-nav {
  padding-bottom: 0;
}

/* Контент прокручивается под стеклянный tab bar */
.scroll-under-nav {
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* Вкладки главного экрана — отступ под плавающий tab bar */
#screen-main .scroll-under-nav {
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}

.screen--full {
  padding-bottom: 0;
}

/* Утилиты */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.text-error {
  color: var(--md-sys-color-error);
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.text-muted {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* Загрузка */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--md-sys-color-surface);
}

.app-loader.hidden {
  display: none !important;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--md-sys-color-surface-container-highest);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Ripple на кастомных элементах */
.ripple-host {
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.ripple-host::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--md-sys-color-on-surface) 10%, transparent 10.01%);
  transform: scale(10);
  opacity: 0;
  transition: transform 0.45s, opacity 0.8s;
  pointer-events: none;
}

.ripple-host:active::after {
  transform: scale(0);
  opacity: 0.12;
  transition: 0s;
}
