/*
 * ingle-app-shell.css
 * Shared application shell for:
 * Welcome, Speak, Play, Listen, Visualize and Improve.
 */

/* ==========================================================================
   1. Design tokens
   ========================================================================== */

:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #152033;
  --muted: #647189;
  --line: #dde4ea;

  --green: #0a8f55;
  --green-dark: #087246;
  --green-soft: #eaf8f1;

  --purple: #7440e8;
  --purple-soft: #f2edff;
  --orange: #f36b32;
  --orange-soft: #fff1e9;
  --blue: #2f67d8;
  --blue-soft: #edf4ff;

  --shadow: 0 18px 48px rgba(30, 43, 59, 0.08);
  --shadow-panel: 0 24px 48px rgba(20, 32, 51, 0.16);

  --radius-lg: 24px;
  --radius-md: 18px;

  --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);
}

/* ==========================================================================
   2. Base
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(
      circle at 10% 0%,
      rgba(10, 143, 85, 0.055),
      transparent 24rem
    ),
    var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   3. Application shell
   ========================================================================== */

.app-shell {
  width: min(100%, 980px);
  margin-inline: auto;
  padding:
    calc(12px + var(--safe-top))
    calc(12px + var(--safe-right))
    calc(22px + var(--safe-bottom))
    calc(12px + var(--safe-left));
}

/* Fixed application frame used by all working pages except Welcome. */
.app-shell--workspace {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding-top: calc(8px + var(--safe-top));
  padding-bottom: var(--safe-bottom);
}

#mss-widget-root {
  width: 100%;
  min-width: 0;
}

#mss-widget-root:has(.app-shell--workspace) {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

/* ==========================================================================
   4. Header and brand
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  min-height: 62px;
  padding: 10px 4px 14px;
}

.app-brand {
  display: inline-flex;
  flex: 0 0 auto;
  flex-direction: column;
  line-height: 1;
  text-decoration: none;
}

.app-brand-word {
  color: #087d49;
  font-size: clamp(1.55rem, 7vw, 2.15rem);
  font-weight: 850;
  letter-spacing: -0.055em;
}

.app-brand-word > span {
  color: #fb4d52;
}

.app-brand-tagline {
  margin-top: 5px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 650;
}

/* Compatibility with tenant-injected brand spans. */
.app-shell .app-brand-word > .ingle-word {
  color: #087d49 !important;
}

.app-shell .app-brand-word > .ingle-dot {
  color: #fb4d52 !important;
}

/* ==========================================================================
   5. Account controls
   ========================================================================== */

.app-account-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
  overflow: visible;
  padding-bottom: 3px;
}

.app-account-label,
.app-account-date {
  display: none;
}

.identityLeft,
.identityWho {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.app-account-pill,
.app-control-pill,
.app-member-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0 11px;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
}

#anonBadge {
  color: var(--muted);
}

.app-control-pill {
  cursor: pointer;
}

.app-member-pill {
  background: #f0f2f5;
  font-weight: 800;
}

.accountPanelAnchor {
  position: relative;
  flex: 0 0 auto;
}

#accountBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  padding-inline: 13px;
  background: #f5f7fa;
  font-weight: 700;
}

#accountBadge:hover {
  border-color: #cbd5df;
  background: #eef2f5;
}

#accountBadge:focus-visible {
  outline: 3px solid rgba(10, 143, 85, 0.22);
  outline-offset: 2px;
}

#accountBadge[aria-expanded="true"] {
  border-color: var(--green);
  background: var(--surface);
}

#accountSelectorToggle {
  flex: 0 0 auto;
  color: inherit;
  font: inherit;
  line-height: 1;
}

#accountBadgeLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   6. Navigation
   ========================================================================== */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  margin-bottom: 12px;
  padding: 6px;
  border: 1px solid rgba(221, 228, 234, 0.92);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(30, 43, 59, 0.07);
  backdrop-filter: blur(16px);
}

.app-shell--workspace .app-nav {
  position: relative;
  top: auto;
  flex: 0 0 auto;
}

.app-tab {
  min-width: 0;
  min-height: 50px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 13px;
  padding: 8px 4px;
  color: #39455a;
  font-size: 0.75rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.app-tab-icon {
  font-size: 1.22rem;
  line-height: 1;
}

.app-tab-home .app-tab-icon {
  font-size: 1.48rem;
}

.app-tab.is-active {
  color: var(--green-dark);
  background: var(--green-soft);
}

/* ==========================================================================
   7. Main content
   ========================================================================== */

.app-main {
  min-width: 0;
}

.app-workspace {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 10px 2px 18px;
}

/* ==========================================================================
   8. Footer
   ========================================================================== */

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 5px 0;
  color: #738095;
  font-size: 0.75rem;
}

.app-shell--workspace .app-footer {
  position: relative;
  z-index: 30;
  min-height: 36px;
  margin: 0;
  padding: 7px 5px calc(6px + var(--safe-bottom));
  background: var(--bg);
}

/* ==========================================================================
   10. Responsive
   ========================================================================== */

/* Mobile: seven fixed destinations. No horizontal scrolling. */
@media (max-width: 759px) {
  .app-nav {
    gap: 2px;
    padding: 5px;
    overflow: visible;
  }

  .app-tab {
    min-height: 54px;
    flex-direction: column;
    gap: 4px;
    padding: 6px 0 5px;
    font-size: 0.6rem;
    line-height: 1;
  }

  .app-tab-icon {
    font-size: 1.24rem;
  }

  .app-tab-home .app-tab-icon {
    font-size: 1.42rem;
  }

  .app-tab-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0;
  }

  .app-tab-label::after {
    content: attr(data-mobile-label);
    font-size: 0.6rem;
  }
}

@media (min-width: 540px) {
  .app-shell {
    padding-inline: 20px;
  }
}

@media (min-width: 760px) {
  .app-shell:not(.app-shell--workspace) {
    padding-top: calc(18px + var(--safe-top));
  }

  .app-header {
    align-items: center;
    padding: 10px 8px 18px;
  }

  .app-account-label,
  .app-account-date {
    display: inline;
    color: #737c8d;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .app-nav {
    width: min(100%, 940px);
    margin: 0 auto 18px;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .app-tab {
    padding-inline: 10px;
    font-size: 0.9rem;
  }
}

@media (min-width: 1060px) {
  .app-shell {
    padding-inline: 34px;
  }

  .app-header {
    padding-inline: 12px;
  }

  .app-nav {
    position: static;
  }
}

@media (max-width: 700px) {
  .app-shell--workspace {
    padding-left: calc(8px + var(--safe-left));
    padding-right: calc(8px + var(--safe-right));
  }

  .app-header {
    gap: 7px;
  }

  .app-brand-tagline,
  .app-account-label,
  .app-account-date {
    display: none;
  }

  .app-account-controls {
    gap: 5px;
  }

  .app-nav {
    margin-bottom: 2px;
  }

  .app-workspace {
    padding-top: 7px;
    padding-bottom: 12px;
  }

  .app-shell--workspace .app-footer {
    min-height: 32px;
    font-size: 0.7rem;
  }
}

@media (max-width: 520px) {
  .app-header {
    align-items: flex-start;
  }

  .identityLeft {
    min-width: 0;
  }

  #anonBadge {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #accountBadge {
    max-width: 126px;
  }
}

@media (max-width: 390px) {
  .app-account-controls {
    font-size: 0.74rem;
  }

  #anonBadge {
    max-width: 88px;
  }

  #accountBadge {
    max-width: 106px;
    padding-inline: 10px;
  }
}

/* ==========================================================================
   11. Utilities and accessibility
   ========================================================================== */

[hidden],
.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
/* ==========================================================================
   Shared account confirmation modal
   ========================================================================== */

.account-confirm {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding:
    calc(18px + var(--safe-top))
    calc(18px + var(--safe-right))
    calc(18px + var(--safe-bottom))
    calc(18px + var(--safe-left));
}

.account-confirm-scrim {
  position: absolute;
  inset: 0;
  background: rgba(21, 32, 51, 0.46);
  backdrop-filter: blur(2px);
}

.account-confirm-card {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(21, 32, 51, 0.24);
}

.account-confirm-card h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1.2;
}

.account-confirm-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.account-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.account-confirm-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 16px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.account-confirm-btn:hover {
  background: var(--surface-soft);
}

.account-confirm-btn.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.account-confirm-btn.primary:hover {
  background: var(--green-dark);
}

.account-confirm-btn:focus-visible {
  outline: 3px solid rgba(10, 143, 85, 0.22);
  outline-offset: 2px;
}

@media (max-width: 520px) {
  .account-confirm {
    align-items: end;
    padding: 10px;
  }

  .account-confirm-card {
    width: 100%;
    border-radius: 18px;
    padding: 20px;
  }

  .account-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .account-confirm-btn {
    width: 100%;
  }
}
.app-shell--workspace {
  grid-template-rows:
    auto
    auto
    minmax(0, 1fr)
    14px;
}


.app-shell-end {
  min-height: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  border-radius:
    0
    0
    var(--radius-lg)
    var(--radius-lg);
  background: var(--surface);
}
/* =========================================================
   Member badge — mobile
   ========================================================= */

@media (max-width: 700px) {
  #accountBadge {
    min-height: 36px;
    max-width: 116px;
    padding-inline: 9px;
  }

  #accountBadgeLabel {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 390px) {
  #accountBadge {
    max-width: 104px;
    padding-inline: 7px;
  }
}
@media (max-width: 700px) {
  .accountBadgeText::after {
    content: "";
  }
}
@media (max-width: 700px) {
  .memberYear {
    display: none;
  }
}
.app-member-slot {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
}

/* ==========================================================================
   12. Persistent shell identity
   ========================================================================== */

.app-member-slot {
  min-width: 0;
  min-height: 36px;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .app-header {
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 10px;
  }

  .app-brand-word {
    font-size: 1.72rem;
  }

  .app-member-slot {
    max-width: 48vw;
  }
}


/* ==========================================================================
   13. Seven-destination navigation
   ========================================================================== */

@media (max-width: 430px) {
  .app-nav {
    gap: 1px;
    padding-inline: 3px;
  }

  .app-tab {
    min-height: 52px;
    gap: 3px;
  }

  .app-tab-icon {
    font-size: 1.14rem;
  }

  .app-tab-home .app-tab-icon {
    font-size: 1.3rem;
  }

  .app-tab-label::after {
    font-size: 0.56rem;
    letter-spacing: -0.01em;
  }
}

@media (max-width: 360px) {
  .app-tab-label::after {
    font-size: 0.52rem;
  }
}
