/* ==========================================================================
   HoraJnana Base CSS & Layout
   Mobile-First (iPhone Safari primary target, fully responsive)
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  font-family: var(--font-family);
  background-color: var(--color-background);
  color: var(--color-on-background);
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  background-color: var(--color-background);
  color: var(--color-on-background);
  line-height: 1.5;
  display: flex;
  justify-content: center;
}

/* App Root Container */
#app-root {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-background);
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
  transition: max-width 0.25s ease;
}

@media (min-width: 768px) {
  #app-root {
    max-width: 820px;
    margin: 20px auto;
    min-height: calc(100vh - 40px);
    min-height: calc(100dvh - 40px);
    border-radius: var(--radius-xl);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    overflow: hidden;
  }
}

@media (min-width: 1024px) {
  #app-root {
    max-width: 980px;
  }
}

/* Screen Shell */
.screen-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  padding-bottom: calc(var(--safe-bottom) + 24px);
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Content Area inside Screen */
.screen-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* Typography tokens mirroring Jetpack Compose Material 3 */
h1, .display-large {
  font-size: 2.25rem;
  line-height: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2, .display-medium {
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3, .title-large {
  font-size: 1.375rem;
  line-height: 1.75rem;
  font-weight: 600;
}

h4, .title-medium {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
}

.body-large {
  font-size: 1rem;
  line-height: 1.5rem;
}

.body-medium {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.body-small {
  font-size: 0.75rem;
  line-height: 1rem;
}

.label-large {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.label-medium {
  font-size: 0.8125rem;
  font-weight: 500;
}

.label-small {
  font-size: 0.6875rem;
  line-height: 0.875rem;
}

.font-bold {
  font-weight: 700;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-on-surface-variant);
  opacity: 0.85;
}

.text-error {
  color: var(--color-error);
}

.spacer-sm { height: 8px; }
.spacer-md { height: 16px; }
.spacer-lg { height: 24px; }
.spacer-xl { height: 32px; }

/* Utility layout classes */
.row {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.row-between {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.col {
  display: flex;
  flex-direction: column;
}

.flex-1 {
  flex: 1;
}

.hidden {
  display: none !important;
}

/* Linear Progress Bar (Top Bar) */
.linear-progress {
  width: 100%;
  height: 3px;
  background-color: var(--color-primary-container);
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 50;
}

.linear-progress-bar {
  width: 100%;
  height: 100%;
  background-color: var(--color-primary);
  animation: indeterminate-progress 1.5s infinite linear;
  transform-origin: 0% 50%;
}

@keyframes indeterminate-progress {
  0% { transform: translateX(-100%) scaleX(0.2); }
  50% { transform: translateX(0%) scaleX(0.6); }
  100% { transform: translateX(100%) scaleX(0.2); }
}

/* Spinner */
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px;
  flex: 1;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3.5px solid var(--color-primary-container);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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