/* Shared header (public and product) and the authenticated shell: navigation, brand selector,
   dialogs, busy/booting states and notice semantics. Glass stays subtle here. */

:root {
  --line: #dddcd3;
  --human: #073D2D;
  --assistance: #4c6157;
  --attention: #7A5A20;
  --product-radius: 16px;
  --product-shadow: 0 8px 28px #073d2d08,0 1px 3px #073d2d06;
  --shell-height: 84px;
  --sidebar-width: 236px;
  --layer-dialog: 70;
}

/* Header */

header {
  display: flex;
  align-items: center;
  min-height: 76px;
  position: sticky;
  top: 0px;
  z-index: 30;
  -webkit-backdrop-filter: blur(var(--blur-glass));
  backdrop-filter: blur(var(--blur-glass));
  height: var(--shell-height);
  padding: 14px 28px;
  gap: 24px;
  background: rgba(255, 252, 246, 0.93);
  box-shadow: rgba(255, 255, 255, 0.533) 0px 1px 0px;
  border-bottom: 1px solid rgb(222, 219, 210);
}

.brand {
  margin-right: auto;
  display: flex;
  align-items: center;
}

.brand img {
  max-width: 100%;
  display: block;
  width: 220px;
  height: auto;
  max-height: 54px;
  object-fit: contain;
}

.product-heading {
  display: none;
}

.demo {
  border-radius: 5px;
  background: rgb(241, 238, 230);
  color: rgb(76, 81, 77);
  font-size: 10px;
  letter-spacing: 0.09em;
  padding: 6px 8px;
}

#menu, #journey #close-menu {
  display: none;
}

/* Authenticated shell */

body.app::before {
  background: radial-gradient(at 70% 0%, rgba(226, 212, 183, 0.267), transparent 65%);
}

body.app::after {
  content: "";
  position: fixed;
  inset: 0px;
  z-index: -1;
  background: linear-gradient(180deg,color-mix(in srgb,var(--bp-brand-ivory) 55%,transparent),color-mix(in srgb,var(--bp-brand-ivory) 80%,transparent)),url('/brand/web/workspace-atmosphere-clean.webp') center/cover no-repeat;
  pointer-events: none;
  opacity: 0.3;
}

body.app .public-nav {
  display: none;
}

.app .brand {
  margin: 0px;
  width: calc(var(--sidebar-width) - 28px);
  flex-shrink: 0;
}

.app .product-heading {
  display: flex;
  flex: 1 1 0%;
  min-width: 0px;
  gap: 8px;
  flex-direction: column;
  border-left: 1px solid var(--line);
  padding-left: 24px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-muted);
}

.app .product-heading > span:first-child {
  font-size: 10px;
  letter-spacing: 0.04em;
}

#header-context {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logout {
  font-size: 12px;
  min-height: 38px;
  padding: 8px 12px;
  background: transparent;
  border-color: var(--line);
}

#workspace {
  margin: auto;
  padding: 24px 28px 52px calc(var(--sidebar-width) + 28px);
  max-width: 1800px;
}

.workspace-head {
  gap: 18px;
  align-items: center;
  margin-bottom: 0px;
  justify-content: space-between;
  padding-bottom: 20px;
  display: flex;
}

.workspace-intro {
  flex: 1 1 0%;
  min-width: 0px;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.workspace-intro .eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
}

.workspace-head h1 {
  font: 500 16px / 1.5 ui-sans-serif, system-ui, sans-serif;
  color: rgb(76, 81, 77);
  letter-spacing: 0px;
  margin: 0px;
}

.workspace-head label {
  width: 260px;
  flex-shrink: 0;
}
#new-brand {
  font-size: 12px;
  white-space: nowrap;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.6);
  border-color: rgb(201, 200, 190);
  min-height: 42px;
  padding: 10px 13px;
}

#new-brand span[aria-hidden] {
  font-size: 17px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0px, 1fr) 270px;
  gap: 22px;
  align-items: start;
}

/* Strategic navigation (fixed sidebar ≥1280px, modal drawer below) */

#journey {
  position: fixed;
  left: 0px;
  bottom: 0px;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 20;
  top: var(--shell-height);
  width: var(--sidebar-width);
  background: linear-gradient(rgba(247, 244, 237, 0.98), rgba(241, 238, 229, 0.95));
  padding: 16px 16px 20px;
  border-right: 1px solid rgb(217, 215, 205);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

#journey.open {
  z-index: 50;
}

#journey button {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  font-size: 13px;
  min-height: 44px;
  border-radius: 7px;
  padding: 8px 12px;
  margin: 1px 0px;
  font-weight: 500;
  color: rgb(68, 78, 71);
  gap: 8px;
  transition: background-color var(--bp-motion-normal) var(--bp-ease), color var(--bp-motion-normal) var(--bp-ease), box-shadow var(--bp-motion-normal) var(--bp-ease);
}

#journey button span {
  margin-right: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgb(90, 97, 91);
}

#journey button:hover {
  background: rgb(233, 235, 227);
  color: var(--bp-brand-emerald-deep);
  border-color: transparent;
}

/* Current place: a raised card with an emerald edge. Solid emerald stays reserved for human commitment. */
#journey button[aria-current] {
  background: var(--surface-card);
  color: var(--human);
  border-color: rgba(201, 174, 130, 0.45);
  box-shadow: inset 3px 0 0 var(--bp-brand-emerald), 0 6px 16px rgba(7, 61, 45, 0.07);
  font-weight: 650;
}

#journey button[aria-current] span {
  color: var(--bp-brand-emerald);
}

/* Journey line (ADR-0023): the numbered phases become nodes joined by a vertical line. Decided phases
   fill their node, the current phase keeps its raised card with an emerald node, and the suggested next
   phase gets a champagne double ring plus a finite, discreet pulse. Words (title, aria-description and the
   badges) carry every state, so neither colour nor motion is the only signal. */
#journey button[data-module] {
  position: relative;
}

#journey button[data-module] > span {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-right: 2px;
  border-radius: 50%;
  border: 1.5px solid rgba(201, 174, 130, 0.75);
  background: var(--bp-brand-ivory);
  font-size: 10px;
  line-height: 1;
}

#journey button[data-module] + button[data-module]::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: calc(12px + 10px);
  top: calc(-50% - 1px);
  height: calc(100% + 2px);
  width: 2px;
  border-radius: 1px;
  background: rgba(201, 174, 130, 0.45);
  pointer-events: none;
}

#journey button[data-module].is-decided > span {
  background: rgb(226, 236, 230);
  border-color: var(--bp-brand-emerald);
  color: var(--bp-brand-emerald-deep);
}

#journey button[data-module][aria-current] > span {
  background: var(--bp-brand-emerald);
  border-color: var(--bp-brand-emerald);
  color: var(--bp-brand-ivory);
}

#journey button[data-module].is-next > span {
  border-color: var(--bp-brand-champagne);
  background: var(--bp-brand-soft-gold, #E2D4B7);
  color: var(--bp-brand-emerald-deep);
  box-shadow: 0 0 0 2px var(--bp-brand-ivory), 0 0 0 3.5px var(--bp-brand-champagne);
  animation: bp-journey-next 2.4s var(--bp-ease) 3;
}

@keyframes bp-journey-next {
  0% { box-shadow: 0 0 0 2px var(--bp-brand-ivory), 0 0 0 3.5px var(--bp-brand-champagne), 0 0 0 3.5px rgba(201, 174, 130, 0.45); }
  70% { box-shadow: 0 0 0 2px var(--bp-brand-ivory), 0 0 0 3.5px var(--bp-brand-champagne), 0 0 0 9px rgba(201, 174, 130, 0); }
  100% { box-shadow: 0 0 0 2px var(--bp-brand-ivory), 0 0 0 3.5px var(--bp-brand-champagne), 0 0 0 9px rgba(201, 174, 130, 0); }
}

#journey .needs-attention::after {
  content: "!";
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  font-size: 10px;
  margin-left: auto;
  color: rgb(98, 71, 25);
  background: rgb(239, 224, 189);
  border-radius: 50%;
  font-weight: 750;
}

#journey #home {
  margin-bottom: 10px;
}

.nav-group {
  text-transform: uppercase;
  font-weight: 700;
  margin: 14px 12px 5px;
  font-size: 10.5px;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
}

/* A precise pointer does not need a 44px target, and four groups do not fit at laptop heights with
   one. Coarse pointers keep the full target, so the drawer on a phone is unchanged. */
@media (pointer: fine) {
  #journey button {
    min-height: 36px;
  }
}

.nav-principle {
  margin: 18px 12px 4px;
  padding-top: 12px;
  border-top: 1px solid rgb(217, 215, 205);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.nav-principle img {
  opacity: 0.85;
}

.nav-principle p {
  font: italic 15px / 1.6 var(--font-display);
  margin: 0px;
  color: rgb(93, 101, 93);
}

.nav-principle strong {
  color: rgb(7, 61, 45);
  font-weight: 400;
}

/* ADR-0022/0024: the journey keeps the principle visible on laptops up to 1040px tall. */
@media (max-height: 1040px) {
  .nav-principle {
    margin-top: 12px;
    padding-top: 10px;
    gap: 10px;
  }

  .nav-principle img {
    width: 20px;
    height: 25px;
  }

  .nav-principle p {
    font-size: 13px;
    line-height: 1.45;
  }
}

#nav-backdrop {
  position: fixed;
  inset: 0px;
  background: var(--bp-glass-backdrop-dark);
  z-index: 40;
}

body.app footer {
  padding-left: calc(var(--sidebar-width) + 28px);
  font-size: 12px;
}

/* Subtle view entry: short, no overshoot. Removed entirely under prefers-reduced-motion. */
#decision > *, #context > * {
  animation: view-enter var(--bp-motion-slow) var(--bp-ease) both;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(6px); }
}

/* Dialogs */

dialog[open] {
  animation: dialog-enter var(--bp-motion-normal) var(--bp-ease);
}

@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
}

dialog {
  border: 1px solid rgb(214, 206, 185);
  border-radius: 18px;
  background: rgb(255, 253, 248);
  color: rgb(22, 27, 25);
  padding: 32px;
  max-width: 540px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 40px);
  box-shadow: rgba(7, 61, 45, 0.2) 0px 24px 90px;
  z-index: var(--layer-dialog);
}

dialog::backdrop {
  background: rgba(10, 36, 27, 0.7);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

dialog h2 {
  font-size: 30px;
}

dialog > p:not(.eyebrow) {
  font-size: 13px;
  color: rgb(96, 107, 89);
}

.new-brand {
  align-items: center;
  gap: 12px;
  display: block;
  padding: 0px;
}

.new-brand input {
  max-width: none;
}

.new-brand label {
  margin: 18px 0px 8px;
}

.new-brand .intake {
  margin: 16px 0px;
}

/* Busy and booting states */

/* Booting hides the page only while the session probe runs (app.js removes the class).
   If scripts or the probe fail, the page reveals itself after 4s instead of staying blank.
   The !important keeps this fallback alive under the reduced-motion override. */
body.booting main {
  visibility: hidden;
  animation: boot-reveal 0s 4s forwards !important;
}

body.booting::after {
  content: "Preparando tu espacio estratégico…";
  position: fixed;
  inset: 40% 0px auto;
  text-align: center;
  font: 500 20px / 1.5 var(--font-display);
  color: rgb(82, 96, 70);
  animation: boot-dismiss 0s 4s forwards !important;
}

@keyframes boot-reveal {
  to { visibility: visible; }
}

@keyframes boot-dismiss {
  to { visibility: hidden; }
}

#workspace[aria-busy="true"]::before {
  content: "";
  position: fixed;
  top: var(--shell-height);
  left: var(--sidebar-width);
  right: 0px;
  height: 2px;
  z-index: 35;
  background: linear-gradient(90deg, rgb(201, 174, 130), rgb(11, 104, 71), rgb(201, 174, 130)) 0% 0% / 200% 100%;
  animation: 1.2s linear 0s infinite normal none running working;
}

@keyframes working {
  100% { background-position: 200% 0px; }
}

/* Status notices dismiss themselves after 7s (app.js); errors stay until the next action. */
body.app #notice {
  max-width: 380px;
}

/* Actionable notices distinguish human corrections from technical failures. */

#notice[data-kind="validation"],
#notice[data-kind="session"] {
  background: var(--status-review-bg);
  color: var(--status-review-text);
  border-color: var(--status-review-text);
}

#notice[data-kind="assistance"] {
  background: var(--evidence-bg);
  color: var(--text-primary);
  border-style: dashed;
  border-color: var(--border-default);
}


/* BRANDOPOLIS: LONG-RUNNING AI ACTIVITY
   Persistent progress for operations whose latency matters.
   Short confirmations remain in #notice. */
.ai-activity {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(880px, calc(100% - 48px));
  margin: 0 auto 18px;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(7,61,45,.96);
  color: #fff;
  box-shadow: 0 14px 34px rgba(7,61,45,.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 12;
}

.ai-activity[hidden] {
  display: none;
}

.ai-activity-mark {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  font-size: 18px;
  line-height: 1;
}

.ai-activity strong {
  display: block;
  color: #fff;
  font-size: .96rem;
  letter-spacing: -.01em;
}

.ai-activity p {
  margin: 3px 0 0;
  color: rgba(255,255,255,.78);
  font-size: .84rem;
}

.ai-activity.is-active .ai-activity-mark {
  animation: brandopolis-ai-pulse 1.6s ease-in-out infinite;
}

.ai-activity.is-complete {
  background: rgba(7,61,45,.92);
}

@keyframes brandopolis-ai-pulse {
  0%,100% { transform: scale(1); opacity: .72; }
  50% { transform: scale(1.08); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #journey button[data-module].is-next > span { animation: none; }
  summary, .panel-toggle { transition: none; }
  .ai-activity,
  .ai-activity-mark {
    transition: none;
    animation: none !important;
  }
}

/* BRANDOPOLIS: AI activity follows the primary strategic work column.
   The memory rail remains visually independent. */
@media (min-width: 1401px) {
  .ai-activity {
    width: calc(100% - 292px);
    max-width: none;
    margin: 0 292px 18px 0;
  }
}

/* BRANDOPOLIS: width calculations include padding and border. */
.ai-activity {
  box-sizing: border-box;
}

/* BRANDOPOLIS: reconciled workspace composition 2026-09-27 */

.app .workspace-head {
  display: none;
}

.primary-workspace {
  min-width: 0;
}
.primary-workspace > .ai-activity {
  width: 100%;
  max-width: none;
  margin: 0 0 18px;
  box-sizing: border-box;
}

/* Brandopolis authenticated header.
   Active brand stays visually centered and the shell remains visible on scroll. */

.app header {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto minmax(320px, auto);
  align-items: center;
  column-gap: 24px;
  position: sticky;
  top: 0;
  z-index: 80;
  background: rgba(250, 248, 242, .97);
  backdrop-filter: blur(14px);
  transition:
    box-shadow .2s ease,
    border-color .2s ease;
}

.app header .brand {
  grid-column: 1;
}

.app header .product-heading {
  grid-column: 2;
}

.app header .header-brand-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;

  display: grid;
  grid-template-columns: auto minmax(180px, 230px);
  align-items: center;
  gap: 10px;
  margin: 0;
}

.app header .header-brand-control label {
  margin: 0;
  color: #315b4f;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.app header .header-brand-control select {
  width: 100%;
  min-width: 190px;
  height: 44px;
  margin: 0;
  padding: 0 38px 0 14px;
  border: 1px solid rgba(7, 61, 45, .26);
  border-radius: 10px;
  background:
    linear-gradient(
      180deg,
      rgba(235, 242, 234, .98),
      rgba(244, 247, 239, .98)
    );
  color: #073d2d;
  font-weight: 750;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .8) inset,
    0 4px 14px rgba(7, 61, 45, .07);
}

.app header .header-brand-control select:hover {
  border-color: rgba(7, 61, 45, .42);
}

.app header .header-brand-control select:focus-visible {
  outline: 3px solid rgba(7, 61, 45, .14);
  outline-offset: 2px;
}

.app header .header-actions {
  grid-column: 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: max-content;
  margin-left: auto;
}

.app header #new-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  margin-left: 0;
  background: rgba(255, 255, 255, .58);
  border-color: var(--line);
  border-radius: 9px;
  box-shadow: none;
}

.app header #new-brand:hover {
  background: rgba(242, 237, 223, .9);
}

.app header #new-brand span[aria-hidden] {
  font-size: 16px;
}

.app header #new-brand,
.app header #mode-badge,
.app header #logout {
  align-self: center;
}

.app header.is-scrolled {
  box-shadow: 0 7px 24px rgba(31, 43, 36, .09);
  border-bottom-color: rgba(7, 61, 45, .16);
}

/* Demo sandbox: unmistakable but unobtrusive, and it always offers the way out to real work. */

.demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--bp-review-border);
  border-radius: var(--bp-radius-lg);
  background: var(--bp-hypothesis-bg);
}

.demo-banner p {
  flex: 1 1 260px;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.demo-banner button {
  flex: 0 0 auto;
}

.badge-demo {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: var(--bp-radius-pill);
  background: var(--bp-brand-emerald);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
