/* ============================================================
   TRC Kids PWA — styles.css
   Palette: #252E2E (dark) / #567577 (teal) / #C9A84C (gold)
            #E8977A (coral) / #62B5BF (aqua) / #FFFFFF (white)
   ============================================================ */

/* ===== Custom Properties — Light Mode (default) ===== */
:root {
  --color-dark:  #252E2E;
  --color-teal:  #567577;
  --color-gold:  #C9A84C;
  --color-coral: #E8977A;
  --color-aqua:  #62B5BF;

  /* Surfaces */
  --bg:        #F4F6F6;
  --surface:   #FFFFFF;
  --surface-2: #EBF0F0;
  --border:    #D8E0E0;

  /* Text */
  --text-primary:   #1A2424;
  --text-secondary: #567577;
  --text-muted:     #8FA8A8;

  /* Chrome */
  --header-bg:   #252E2E;
  --header-text: #FFFFFF;

  /* Tabs */
  --tab-active-bg:    #252E2E;
  --tab-active-text:  #FFFFFF;
  --tab-inactive-bg:  #EBF0F0;
  --tab-inactive-text: #567577;

  /* Buttons */
  --btn-view-bg:       #62B5BF;
  --btn-view-text:     #FFFFFF;
  --btn-guide-bg:      #E8977A;
  --btn-guide-text:    #FFFFFF;
  --btn-individual-bg: #C9A84C;
  --btn-individual-text: #FFFFFF;
  --btn-images-bg:     #567577;
  --btn-images-text:   #FFFFFF;
  --btn-disabled-bg:   #DDE5E5;
  --btn-disabled-text: #9BB0B0;

  /* Shadows */
  --shadow-card: 0 1px 4px rgba(37,46,46,0.10), 0 2px 8px rgba(37,46,46,0.06);
}

/* ===== Custom Properties — Dark Mode ===== */
[data-theme="dark"] {
  --bg:        #141C1C;
  --surface:   #1C2626;
  --surface-2: #222E2E;
  --border:    #2C3C3C;

  --text-primary:   #E8F0F0;
  --text-secondary: #7AABAB;
  --text-muted:     #4E6868;

  --header-bg:   #111919;
  --header-text: #FFFFFF;

  --tab-active-bg:     #62B5BF;
  --tab-active-text:   #111919;
  --tab-inactive-bg:   #1C2626;
  --tab-inactive-text: #7AABAB;

  --btn-disabled-bg:   #252E2E;
  --btn-disabled-text: #3E5050;

  --shadow-card: 0 1px 4px rgba(0,0,0,0.4), 0 2px 12px rgba(0,0,0,0.3);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

/* ===== App Header ===== */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 16px 8px;
  padding-top: max(12px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 640px;
  margin: 0 auto;
}

.logo {
  height: 34px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.logo-fallback {
  font-size: 20px;
  font-weight: 700;
  color: var(--header-text);
  letter-spacing: 0.04em;
}

.theme-toggle {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover { background: rgba(255,255,255,0.22); }
.theme-toggle:active { transform: scale(0.94); }

.week-label {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-top: 6px;
  min-height: 14px;
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 68px;
  z-index: 99;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  transition: background 0.2s, border-color 0.2s;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-width: 72px;
  padding: 10px 6px;
  border: none;
  border-bottom: 2px solid transparent;
  background: var(--tab-inactive-bg);
  color: var(--tab-inactive-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.tab.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  border-bottom-color: var(--color-aqua);
}

/* ===== Content Area ===== */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.tab-section       { display: none; }
.tab-section.active { display: block; }

/* ===== Room Cards ===== */
.room-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}

.room-card-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.room-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.room-age {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.room-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 13px 16px;
  border-radius: 9px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s, filter 0.15s;
  width: 100%;
  text-align: center;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(0.92);
}

.btn-icon { font-size: 16px; flex-shrink: 0; }

.btn-view       { background: var(--btn-view-bg);       color: var(--btn-view-text); }
.btn-guide      { background: var(--btn-guide-bg);      color: var(--btn-guide-text); }
.btn-individual { background: var(--btn-individual-bg); color: var(--btn-individual-text); }
.btn-images     { background: var(--btn-images-bg);     color: var(--btn-images-text); }

.btn-disabled {
  background: var(--btn-disabled-bg);
  color: var(--btn-disabled-text);
  cursor: default;
  pointer-events: none;
  font-style: italic;
}

/* ===== Resources Section ===== */
.resource-list { list-style: none; }

.resource-section-header {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 20px 0 8px;
  padding-left: 2px;
}

.resource-item {
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: background 0.2s;
}

.resource-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  text-decoration: none;
  color: var(--text-primary);
  border-radius: 12px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.resource-link:hover,
.resource-link:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.resource-icon  { font-size: 20px; flex-shrink: 0; }
.resource-label { font-size: 15px; font-weight: 600; flex: 1; }
.resource-arrow { color: var(--text-muted); font-size: 20px; font-weight: 300; }

.resource-link--btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.resource-item--disabled {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  opacity: 0.5;
}

.resource-item--disabled .resource-label { font-size: 15px; font-weight: 600; flex: 1; }
.coming-soon { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }

/* ===== Loading / Empty States ===== */
.loading-state,
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== In-App PDF Viewer ===== */
.pdf-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.pdf-viewer[hidden] { display: none; }

.pdf-viewer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pdf-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px 6px 4px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.pdf-back-btn:active { opacity: 0.6; }
.pdf-back-arrow { font-size: 22px; font-weight: 300; line-height: 1; }

.pdf-viewer-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ===== Image Modal ===== */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal[hidden] { display: none; }

.image-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
}

.image-modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.image-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.image-modal-close:hover { background: rgba(255,255,255,0.30); }

.image-viewer {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.image-viewer img {
  flex: 1;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 8px;
  user-select: none;
  -webkit-user-drag: none;
}

.img-nav {
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}

.img-nav:hover:not(:disabled) { background: rgba(255,255,255,0.30); }
.img-nav:disabled { opacity: 0.25; cursor: default; }

.image-counter {
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
}

/* ===== Responsive: 2-column buttons on wider screens ===== */
@media (min-width: 440px) {
  .room-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Focus styles for accessibility ===== */
.btn:focus-visible,
.tab:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-aqua);
  outline-offset: 2px;
}
