/* THEORIA visitor shell — shared from captive portal through exhibits */

:root {
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, Cambria, "Times New Roman", Times, serif;
  --font-display: var(--font-serif);
  --header-title-font: var(--font-serif);
  --header-height-vh: 12;
  --header-logo-size: 42px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --parchment: #f4f1ec;
  --parchment-dark: #ebe7e1;
  --parchment-deeper: #ddd8d1;
  --ink: #1a2228;
  --ink-light: #2d3840;
  --ink-faint: #5a6570;
  --accent: #b8653a;
  --accent-light: #d07d52;
  --accent-pale: #f0e6de;
  --accent-alt: #24303a;
  --accent-alt-light: #3d4a55;
  --white-warm: #ffffff;
  --shadow: color-mix(in srgb, var(--ink) 11%, transparent);
  --shadow-soft: color-mix(in srgb, var(--ink) 5%, transparent);
  --flow-bg: var(--parchment);
  --status-ok-line: #9cc5a6;
  --status-ok-bg: #edf8ef;
  --status-ok-text: #1b5e2f;
  --status-fail-line: #dfb4b4;
  --status-fail-bg: #fff2f2;
  --status-fail-text: #8a2b2b;
  --portal-bg-image: none;
  --portal-overlay-color: rgba(24, 18, 14, 0);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body.visitor-app {
  margin: 0;
  overscroll-behavior: none;
  background-color: var(--parchment);
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, color-mix(in srgb, var(--accent) 7%, transparent) 0%, transparent 55%),
    linear-gradient(180deg, color-mix(in srgb, var(--parchment) 96%, white 4%) 0%, var(--parchment) 100%);
}

body.visitor-guide {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body.visitor-portal {
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  background-image:
    linear-gradient(var(--portal-overlay-color), var(--portal-overlay-color)),
    var(--portal-bg-image),
    radial-gradient(ellipse 120% 80% at 50% -20%, color-mix(in srgb, var(--accent) 7%, transparent) 0%, transparent 55%),
    linear-gradient(180deg, color-mix(in srgb, var(--parchment) 96%, white 4%) 0%, var(--parchment) 100%);
  background-size: auto, cover, auto, auto;
  background-position: center, center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
}

/* ── Museum header (portal + guide) ── */

.header {
  background: var(--ink);
  color: var(--parchment);
  padding: calc(14px + max(env(safe-area-inset-top, 0px), var(--sim-safe-area-top, 0px))) 20px 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  z-index: 20;
  flex-shrink: 0;
  min-height: calc(var(--header-height-vh, 12) * 1dvh);
}

.header.has-header-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

.header-avatar {
  width: var(--header-logo-size, 42px);
  height: var(--header-logo-size, 42px);
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--parchment);
  flex-shrink: 0;
  border: 1.5px solid var(--accent-alt);
}

.header-logo {
  display: none;
  width: auto;
  height: auto;
  max-width: calc(var(--header-logo-size, 42px) * 4.3);
  max-height: var(--header-logo-size, 42px);
  object-fit: contain;
  flex-shrink: 0;
  align-self: flex-start;
}

.header-info {
  flex: 1;
  min-width: 0;
  min-height: var(--header-logo-size, 42px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-title {
  font-family: var(--header-title-font, var(--font-display));
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-wrap: balance;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-height: var(--header-logo-size, 42px);
}

.lang-switcher {
  display: flex;
  align-items: center;
}

.lang-menu {
  position: relative;
}

.lang-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, white 25%, transparent 30%);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--parchment);
  cursor: pointer;
  transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.lang-menu-trigger:hover {
  border-color: color-mix(in srgb, var(--accent) 78%, white 22%);
  background: color-mix(in srgb, var(--accent) 18%, transparent 82%);
}

.lang-menu-trigger:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 80%, white 20%);
  outline-offset: 2px;
}

.lang-menu-trigger[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent) 82%, white 18%);
  border-color: color-mix(in srgb, var(--accent) 90%, white 10%);
  color: color-mix(in srgb, var(--ink) 92%, black 8%);
}

.lang-menu-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.lang-menu-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lang-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 176px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, white 72%);
  border-radius: calc(var(--radius-md) + 2px);
  background: color-mix(in srgb, var(--white-warm) 96%, var(--accent) 4%);
  box-shadow: 0 14px 36px rgba(16, 38, 61, 0.18);
}

.lang-menu-dropdown[hidden] {
  display: none;
}

.lang-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-out);
}

.lang-menu-item:hover,
.lang-menu-item:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, white 90%);
  outline: none;
}

.lang-menu-item.active {
  background: color-mix(in srgb, var(--accent) 16%, white 84%);
}

.lang-menu-item-code {
  flex-shrink: 0;
  min-width: 2rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ink) 68%, var(--accent) 32%);
}

.lang-menu-item-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.lang-menu-item-check {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: color-mix(in srgb, var(--accent) 78%, var(--ink) 22%);
}

@media (max-width: 700px) {
  .header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "media info"
      "media actions";
    align-items: start;
    row-gap: 6px;
  }

  .header-avatar,
  .header-logo {
    grid-area: media;
    align-self: start;
  }

  .header-info {
    grid-area: info;
    min-height: auto;
    justify-content: flex-start;
  }

  .header-title {
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .header-actions {
    grid-area: actions;
    width: 100%;
    margin-left: 0;
    min-height: auto;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* ── Shared exhibit surface ── */

.exhibit-hero {
  max-width: 42rem;
  width: 100%;
  margin: 16px auto 20px;
  padding: 0 16px;
  box-sizing: border-box;
}

.exhibit-hero-frame {
  border-radius: 16px;
  overflow: hidden;
  background: var(--parchment-dark);
  aspect-ratio: 16 / 9;
}

.exhibit-hero-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.exhibit-content {
  max-width: 42rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}

body.static-exhibit-mode .exhibit-content,
body.audio-exhibit-mode .exhibit-content {
  padding-top: 0;
}

.exhibit-card {
  background: var(--white-warm);
  border: 1px solid color-mix(in srgb, var(--parchment-deeper) 88%, var(--ink) 12%);
  border-radius: 4px 16px 16px 16px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  box-shadow: 0 1px 3px var(--shadow-soft);
}

.exhibit-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  max-width: 42rem;
  width: 100%;
}

.exhibit-actions--row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.exhibit-action-btn {
  appearance: none;
  width: 100%;
  background: var(--white-warm);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--parchment-deeper) 78%);
  color: var(--ink);
  padding: 12px 18px;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.22s var(--ease-out), border-color 0.22s var(--ease-out), transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 2px var(--shadow-soft);
}

.exhibit-action-btn::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.exhibit-action-btn:hover:not(:disabled) {
  background: var(--accent-pale);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--parchment-deeper) 45%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--shadow-soft);
}

.exhibit-action-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, white 30%);
  outline-offset: 2px;
}

.exhibit-action-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.exhibit-action-btn[aria-current="true"],
.exhibit-action-btn.is-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--white-warm) 86%);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--parchment-deeper) 50%);
  font-weight: 600;
}

.exhibit-action-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.exhibit-action-btn--quiet {
  width: auto;
  flex: 1 1 auto;
}

.exhibit-action-btn--end {
  margin-left: auto;
  width: auto;
  flex: 0 1 auto;
}

.exhibit-action-btn--primary {
  justify-content: center;
  text-align: center;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--parchment);
  font-weight: 600;
}

.exhibit-action-btn--primary::before {
  display: none;
}

.exhibit-action-btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 90%, var(--accent) 10%);
  border-color: color-mix(in srgb, var(--ink) 90%, var(--accent) 10%);
  color: var(--parchment);
}

.audio-chapter-list .exhibit-action-btn {
  width: 100%;
}

/* ── Visitor copy + layout helpers ── */

.visitor-main {
  flex: 1;
  width: 100%;
}

.visitor-eyebrow {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--parchment-deeper) 88%, var(--ink) 12%);
  background: color-mix(in srgb, var(--white-warm) 92%, var(--accent-pale) 8%);
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.visitor-display-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: balance;
}

.visitor-lead {
  margin: 0;
  color: var(--ink-faint);
  line-height: 1.55;
  font-size: 15px;
  text-wrap: pretty;
}

.visitor-sublead {
  margin: 10px 0 0;
  color: var(--ink-faint);
  line-height: 1.5;
  font-size: 14px;
}

.visitor-note-title {
  display: block;
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.visitor-steps {
  margin: 0;
  padding-left: 18px;
  line-height: 1.6;
  color: var(--ink-faint);
  font-size: 14px;
}

.visitor-pill {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 14px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--parchment-deeper) 80%);
  background: var(--accent-pale);
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.visitor-powered-by {
  max-width: 42rem;
  margin: 0 auto;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  font-size: 11px;
  letter-spacing: 0.03em;
  color: color-mix(in srgb, var(--ink-faint) 88%, var(--ink) 12%);
  text-align: center;
  opacity: 0.82;
}

.visitor-status {
  margin-top: 4px;
}

.visitor-status.ok {
  border-color: var(--status-ok-line);
  background: var(--status-ok-bg);
}

.visitor-status.ok .visitor-status-text {
  color: var(--status-ok-text);
}

.visitor-status.fail {
  border-color: var(--status-fail-line);
  background: var(--status-fail-bg);
}

.visitor-status.fail .visitor-status-text {
  color: var(--status-fail-text);
}

.visitor-status-text {
  margin: 0;
  font-size: 14px;
  color: var(--ink-faint);
  line-height: 1.5;
}

.visitor-portal-shell {
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 16px 16px 8px;
  box-sizing: border-box;
}

.visitor-portal-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.visitor-portal-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.visitor-card-muted {
  background: color-mix(in srgb, var(--white-warm) 88%, var(--parchment) 12%);
}

@media (min-width: 760px) {
  .visitor-portal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(16rem, 0.8fr);
    align-items: start;
  }

  .visitor-portal-grid > .exhibit-card:first-child {
    padding: 22px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .exhibit-action-btn:hover:not(:disabled),
  .exhibit-action-btn:active:not(:disabled) {
    transform: none;
  }

  .exhibit-action-btn,
  .lang-menu-trigger {
    transition-duration: 0.01ms;
  }
}
