/* Shared app shell. Page features own their content; this file owns the frame. */
:root {
  --app-header-height: 76px;
  --shell-width: 1240px;
}

html {
  scrollbar-gutter: stable;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 180px;
  align-items: center;
  width: 100%;
  max-width: var(--shell-width);
  height: var(--app-header-height);
  min-height: var(--app-header-height);
  margin: 0 auto;
  padding: 0 30px;
  gap: 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  gap: 8px;
}

.wordmark-symbol {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 15px;
}

.wordmark-name {
  font-size: 14px;
}

.main-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow: visible;
}

.nav-link {
  flex: 0 0 auto;
  font-weight: 700;
  white-space: nowrap;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  min-width: 0;
  justify-self: end;
}

.display-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 10px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.display-mode-switch button {
  border: 0;
  border-radius: 4px;
  padding: 4px 7px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  white-space: nowrap;
}

.display-mode-switch button.is-active {
  color: var(--text);
  background: var(--accent-soft);
  font-weight: 700;
}

.hardware-surface-placeholder {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 70px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

body[data-display-mode="hardware"] .hardware-surface-placeholder {
  display: flex;
}

.hardware-surface-placeholder strong {
  color: var(--text);
  font-size: 12px;
}

.header-route {
  color: var(--text);
  font-weight: 700;
}

.status-divider {
  color: var(--line);
}

main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--shell-width);
  margin: 0 auto;
}

.site-footer {
  width: 100%;
  max-width: var(--shell-width);
  margin: 0 auto;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

/* Keep workspace pages in the same shell; only their inner feature changes. */
body[data-route="practice"] .site-header,
body[data-route="rhythm"] .site-header {
  display: grid;
}

body[data-page-kind="workspace"] main {
  height: calc(100dvh - var(--app-header-height));
  max-height: calc(100dvh - var(--app-header-height));
  overflow: auto;
}

@media (max-width: 700px) {
  :root {
    --app-header-height: 86px;
  }

  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 43px 39px;
    width: 100%;
    max-width: none;
    height: var(--app-header-height);
    min-height: var(--app-header-height);
    gap: 0 10px;
    padding: 5px 12px 0;
  }

  .wordmark {
    min-width: 0;
  }

  .wordmark-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    align-self: stretch;
    gap: 2px;
  }

  .nav-link {
    padding: 7px 9px;
    font-size: 11px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .header-status {
    gap: 5px;
    font-size: 10px;
  }

  .display-mode-switch {
    margin-left: 4px;
  }

  .display-mode-switch button {
    padding: 4px 6px;
    font-size: 9px;
  }

  .header-status .status-dot,
  .header-status .status-divider {
    display: none;
  }

  body[data-route="practice"][data-page-kind="workspace"] main {
    height: calc(100dvh - var(--app-header-height)) !important;
    max-height: calc(100dvh - var(--app-header-height)) !important;
    overflow: auto;
  }

  main {
    max-width: none;
  }
}

/* Final compact-display overrides. These come after the legacy page rules so
   every route receives the same landscape frame. */
@media (max-width: 1000px) and (orientation: landscape) {
  :root { --app-header-height: 52px; }
  body { overflow: hidden; }
  .app-shell { width: 100%; height: 100dvh; min-height: 100dvh; }
  .site-header { grid-template-columns: 102px minmax(0, 1fr) auto; width: 100%; max-width: none; height: 52px; min-height: 52px; gap: 8px; padding: 0 10px; }
  .wordmark-symbol { width: 23px; height: 23px; font-size: 12px; }
  .wordmark-name { font-size: 11px; }
  .wordmark-caption { display: none; }
  .main-nav { min-width: 0; overflow-x: auto; }
  .nav-link { padding: 6px 8px; font-size: 11px; }
  .header-status { font-size: 9px; }
  .header-status > span:not(.header-route):not(.status-dot) { display: none; }
  main { width: 100%; max-width: none; height: calc(100dvh - 52px); max-height: none; margin: 0; padding: 0 14px 18px; overflow: auto; }
  body[data-page-kind="teaching"] main,
  body[data-page-kind="workspace"] main,
  body[data-page-kind="interactive"] main { overflow: hidden; }
  .view { padding-top: 24px; }
  .view-heading { margin-bottom: 22px; }
  .view-heading h1 { font-size: 32px; }
  .view-heading .lead { font-size: 12px; }
  .site-footer { display: none; }
}

@media (max-width: 700px) and (orientation: portrait) {
  :root { --app-header-height: 52px; }
  body { overflow: hidden; background: var(--bg); }
  .app-shell { position: fixed; top: 50%; left: 50%; width: 100dvh; height: 100dvw; min-height: 0; overflow: hidden; transform: translate(-50%, -50%) rotate(90deg); transform-origin: center; }
  .site-header { display: grid; grid-template-columns: 102px minmax(0, 1fr) auto; grid-template-rows: 1fr; width: 100%; max-width: none; height: 52px; min-height: 52px; gap: 8px; padding: 0 10px; }
  .wordmark-symbol { width: 23px; height: 23px; font-size: 12px; }
  .wordmark-name { font-size: 11px; }
  .wordmark-caption { display: none; }
  .main-nav { grid-column: 2; grid-row: 1; min-width: 0; overflow-x: auto; }
  .nav-link { padding: 6px 7px; font-size: 10px; }
  .header-status { grid-column: 3; grid-row: 1; font-size: 9px; }
  .header-status > span:not(.header-route):not(.status-dot) { display: none; }
  main { position: static; width: auto; height: calc(100% - 52px); max-height: none; margin: 0; padding: 0 10px 10px; transform: none; overflow: auto; }
  body[data-page-kind="teaching"] main,
  body[data-page-kind="workspace"] main,
  body[data-page-kind="interactive"] main { overflow: hidden; }
  .view { padding-top: 18px; }
  .view-heading { margin-bottom: 16px; }
  .view-heading h1 { font-size: 27px; }
  .view-heading .lead { font-size: 11px; }
  .site-footer { display: none; }
}
