@import url('./tokens.css');

/* ---- Screen reader utility ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Focus indicator ---- */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--cream);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* ---- Install banner ---- */
.install-banner {
  background: var(--coral);
  color: var(--white);
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  border-bottom: var(--border-ink);
  flex-shrink: 0;
}
.install-dismiss {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
}

/* ---- App header ---- */
.app-header {
  background: var(--grad-hero);
  border-bottom: var(--border-ink);
  display: flex;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 0.5rem) 1rem 0.5rem;
  min-height: calc(env(safe-area-inset-top) + 104px);
  gap: 0.65rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.app-header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  position: relative;
  z-index: 1;
}
.app-header::before {
  content: '';
  position: absolute;
  right: -80px;
  top: 50%;
  transform: translateY(-50%);
  width: 320px;
  height: 320px;
  background-image: url('../images/logo-badge.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.18;
  pointer-events: none;
}
.app-logo {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-ink);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  cursor: pointer;
}
.app-name-group { cursor: pointer; }
.app-title {
  font-family: 'Bangers', cursive;
  letter-spacing: 3px;
  font-size: 1rem;
  color: var(--sand);
  line-height: 1;
}
.app-sub {
  font-family: 'Space Mono', monospace;
  font-size: 0.5rem;
  color: rgba(232,200,74,0.55);
  letter-spacing: 1px;
}
.header-search-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 220px;
}
.header-search {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-pill);
  padding: 0.3rem 1.9rem 0.3rem 0.75rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.85);
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  outline: none;
}
.header-search::placeholder { color: rgba(255,255,255,0.5); }
.header-search:focus {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.45);
}
.header-search-clear {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255,255,255,0.18);
  color: var(--white);
  border-radius: 50%;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.header-search-clear:hover { background: rgba(255,255,255,0.3); }
@media (min-width: 600px) {
  .header-search-wrap { max-width: 240px; }
}
@media (min-width: 768px) {
  .app-logo { width: 200px; height: 200px; }
}

/* ---- Screen container ---- */
#screen-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---- Screens ---- */
.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.hidden { display: none !important; }

/* ---- Bottom tabs (mobile default) ---- */
.bottom-tabs {
  display: flex;
  border-top: var(--border-ink);
  background: var(--white);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.25rem 0.3rem;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  color: var(--text-light);
  border-right: 1px solid rgba(26,18,9,0.1);
  transition: color 0.15s, background 0.15s;
  min-height: 44px;
}
.tab:last-child { border-right: none; }
.tab.active { color: var(--coral); background: var(--cream); }
.tab-icon { font-size: 1.1rem; display: block; margin-bottom: 0.1rem; }
.tab-label { line-height: 1; }

/* ---- Desktop: sidebar layout ---- */
@media (min-width: 1200px) {
  body {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 220px 1fr;
  }
  .app-header {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .bottom-tabs {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
    width: 220px;
    border-top: none;
    border-right: var(--border-ink);
    overflow-y: auto;
    align-items: stretch;
    flex-shrink: 0;
  }
  #screen-container {
    grid-column: 2;
    grid-row: 2;
  }
  .tab {
    flex: none;
    flex-direction: row;
    padding: 0.85rem 1.25rem;
    gap: 0.7rem;
    justify-content: flex-start;
    border-right: none;
    border-bottom: 1px solid rgba(26,18,9,0.08);
    border-left: 3px solid transparent;
    font-size: 0.75rem;
  }
  .tab.active { border-left-color: var(--coral); background: var(--cream); }
  .tab-icon { font-size: 1.1rem; }
  .header-search { width: 240px; }
}

/* ---- Header user button ---- */
.header-user-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-pill);
  color: var(--sand);
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background 0.15s;
  white-space: nowrap;
}
.header-user-btn:hover { background: rgba(255,255,255,0.25); }
.header-user-btn.signed-in {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: var(--grad-coral);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-ink);
  font-family: 'Bangers', cursive;
  font-size: 1.4rem;
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.header-user-btn.signed-in img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Shared components ---- */
.section-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  padding: 0.4rem 1rem;
  background: var(--paper);
  border-bottom: 1px solid rgba(26,18,9,0.1);
}
.back-btn {
  display: inline-flex;
  align-items: center;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(26,18,9,0.08);
  width: 100%;
}
.back-btn:hover { color: var(--coral); }

/* Gradient header utility classes (with solid-colour fallback for iOS WebKit) */
.grad-coral  { background-color: #B0532F; background-image: linear-gradient(135deg, #D4694A 0%, #A8442A 100%); }
.grad-sky    { background-color: #25739A; background-image: linear-gradient(135deg, #2E86AB 0%, #1B4F6B 100%); }
.grad-amber  { background-color: #BC901C; background-image: linear-gradient(135deg, #D4A820 0%, #B07818 100%); }
.grad-lime   { background-color: #3D7A35; background-image: linear-gradient(135deg, #4a8f3f 0%, #2d5c28 100%); }
.grad-pink   { background-color: #A74565; background-image: linear-gradient(135deg, #c4607a, #8a3050); }
.grad-teal   { background-color: #248578; background-image: linear-gradient(135deg, #2a9d8f, #1a6b60); }

/* Primary button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--grad-coral);
  color: var(--white);
  border: var(--border-ink);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-ink);
  font-family: 'Bangers', cursive;
  letter-spacing: 2px;
  font-size: 1rem;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.btn-primary:hover {
  box-shadow: var(--shadow-ink-lg);
  transform: translate(-2px, -2px);
}

/* Secondary button */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-ink);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-ink);
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
}
