/* layout.css — Screen routing, responsive, app container */

.app-container {
  position: relative;
  z-index: var(--z-app);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Screen base */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.hidden {
  display: none;
}

.screen-active {
  opacity: 1;
  pointer-events: auto;
}

.screen-exit {
  opacity: 0;
}

.screen-content {
  padding: var(--space-lg);
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Beach scene sits behind the app */
.beach-scene {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-beach);
  pointer-events: none;
  overflow: hidden;
}

/* Pixel title */
.pixel-title {
  font-family: var(--font-pixel);
  font-size: 28px;
  color: var(--accent);
  text-align: center;
  text-shadow:
    2px 2px 0 var(--text-primary),
    4px 4px 0 rgba(0,0,0,0.1);
  line-height: 1.4;
  margin-bottom: var(--space-sm);
  image-rendering: pixelated;
}

.pixel-title-sm {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--accent);
  image-rendering: pixelated;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: var(--space-lg);
}

/* Pixel button */
.btn-pixel {
  display: block;
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-pixel);
  font-size: 12px;
  text-align: center;
  color: white;
  background: var(--accent);
  border: 3px solid rgba(0,0,0,0.2);
  border-radius: var(--radius-md);
  box-shadow:
    0 4px 0 rgba(0,0,0,0.15),
    0 6px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: all 0.1s ease;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent;
}

.btn-pixel:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0,0,0,0.15),
    0 3px 6px rgba(0,0,0,0.1);
}

.btn-pixel.btn-primary {
  background: var(--accent);
  font-size: 14px;
  padding: 18px 24px;
  margin-bottom: var(--space-md);
}

.btn-pixel.btn-secondary {
  background: var(--text-secondary);
  font-size: 10px;
  margin-bottom: var(--space-sm);
}

.btn-pixel.btn-sm {
  font-size: 9px;
  padding: 8px 14px;
  width: auto;
  display: inline-block;
}

.btn-pixel.btn-danger {
  background: var(--danger);
  font-size: 10px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-primary);
  background: var(--bg-card);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform var(--transition-fast);
}

.btn-icon:active {
  transform: scale(0.9);
}

/* Word highlight in sentences */
.word-highlight {
  background: linear-gradient(180deg, transparent 60%, var(--accent-glow) 60%);
  padding: 0 2px;
  font-weight: 700;
  color: var(--accent);
  border-radius: 2px;
}

/* Responsive */
@media (max-width: 374px) {
  .pixel-title { font-size: 22px; }
  .screen-content { padding: var(--space-md); }
}

/* iPad */
[data-device="ipad"] .screen-content {
  max-width: 600px;
  margin: 0 auto;
}

/* Mac */
[data-device="mac"] {
  /* Mac layout: potential side-by-side for landscape */
}

[data-device="mac"] .screen-content {
  max-width: 700px;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  [data-device="mac"] .app-container {
    display: flex;
  }

  [data-device="mac"] .beach-scene {
    position: fixed;
    width: 35%;
    height: 100%;
    left: 0;
  }

  [data-device="mac"] .app-container {
    margin-left: 35%;
    width: 65%;
  }
}

/* Offline indicator */
body.offline::after {
  content: 'Offline';
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warning);
  color: white;
  font-size: 10px;
  font-family: var(--font-pixel);
  padding: 4px 12px;
  border-radius: 0 0 4px 4px;
  z-index: var(--z-toast);
}

/* === LOADING OVERLAY === */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #4A90D9, #87CEEB, #B0E0E6, #F4D9A0);
  transition: opacity 0.5s ease;
  opacity: 1;
}

.app-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  animation: loading-pulse 2s ease-in-out infinite;
}

.loading-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: bounce-in 0.6s ease-out;
}

.loading-text {
  font-family: var(--font-pixel, monospace);
  font-size: 12px;
  color: white;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
  margin-bottom: 8px;
}

.loading-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  max-width: 260px;
  line-height: 1.5;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
