@import "./variables.css";
@import "./utils.css";
@import "./components.css";

/* ==========================================================================
   CSS Reset & Normalize
   ========================================================================== */

/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margin and padding */
* {
  margin: 0;
  padding: 0;
}

/* Prevent font size inflation */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Remove default margin in favour of better control in authored CSS */
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

/* Remove list styles on ul, ol elements with a list role */
ul[role="list"],
ol[role="list"] {
  list-style: none;
}

/* Set shorter line heights on headings and interactive elements */
h1,
h2,
h3,
h4,
h5,
h6,
button,
input,
label {
  line-height: 1.1;
}

/* Balance text wrapping on headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */
img,
picture,
svg {
  max-width: 100%;
  display: block;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* Make sure textareas without a rows attribute are not tiny */
textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   App Specific Styles
   ========================================================================== */

html,
body {
  max-width: 100vw;
  max-height: 100svh;
  width: 100%;
  height: 100%;
  line-height: 1.5;
  overflow: hidden; /* подавляем нативный скролл выше main */
  overscroll-behavior: none;
}

:root {
  /* Safe-area insets with CSS env fallback */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Dynamic 1vh (in px), updated from JS */
  --vh: 1vh;

  /* Heights from Telegram (optional) */
  --viewport-height: 100svh;
  --viewport-stable-height: 100svh;

  /* Dynamic header gap between top edge and safe area start */
  --header-gap: var(--safe-top);
  /* Extra free space under Telegram controls (6 spacings) */
  --header-top-extra: calc(var(--spacing) * 6);
  --footer-bottom-extra: calc(var(--spacing) * 6);
}

body {
  color: var(--foreground);
  background: var(--background);
  font-family: var(--font-tt-dogma-normal);
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Корневой контейнер приложения: без внешнего скролла */
#root {
  height: 100%;
  overflow: hidden;
}
:root[data-theme="dark"] {
  #loader {
    filter: invert(1);
  }
}
@media (prefers-color-scheme: dark) {
  #loader {
    filter: invert(1);
  }
}

main {
  /* exact safe area box */
  min-height: calc(100 * var(--vh) - var(--safe-top) - var(--safe-bottom));
  box-sizing: border-box;
  overflow: hidden;
}
main:has(#loader) {
  padding: 0;
}

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

/* Optional scroll helper */
.content-scroll {
  height: 100%;
  min-height: 0; /* allow flex children to shrink */
  overflow: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  html {
    color-scheme: dark;
  }
}

/* TT Dogma Font Utilities */
.font-dogma-normal {
  font-family: var(--font-tt-dogma-normal);
  font-weight: 450;
}

.font-dogma-medium {
  font-family: var(--font-tt-dogma-medium);
  font-weight: 500;
}

.font-dogma-bold {
  font-family: var(--font-tt-dogma-bold);
  font-weight: 700;
}

/* Reset button styles */
button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
}

input {
  appearance: none;
  text-align: left;
}
