/* Code view: the same page, drawn the way a programmer sees it */

/* The switch in the header */
.view-toggle {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.4;
  color: var(--on-red); background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 999px;
  padding: 0.2rem 0.7rem; cursor: pointer;
}
.view-toggle:hover { background: rgba(255, 255, 255, 0.14); }
.view-toggle:focus-visible { outline: 2px solid var(--on-red); outline-offset: 3px; }
.view-toggle[aria-pressed="true"] { background: var(--on-red); color: var(--accent); }
.view-toggle[hidden] { display: none; }

/* Labels are added by the script, and only show in code view */
.code-tag { display: none; }

.is-code-view main {
  background: #1e2227;
  box-shadow: none;
  transition: background-color 0.3s ease;
}
.is-code-view main,
.is-code-view main * { color: rgba(236, 238, 240, 0.45); }

/* Quiet the backgrounds so the structure shows */
.is-code-view main .story-hero {
  background-color: transparent; background-image: none;
  border-bottom-color: rgba(232, 138, 120, 0.4);
}
.is-code-view main :is(.story-aside, .draft-note, .card) {
  background: transparent; box-shadow: none;
}
.is-code-view main .button {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(236, 238, 240, 0.35);
}
.is-code-view main :is(input, select, textarea) {
  background: #2b3036; border-color: #444b53;
}
.is-code-view main img { opacity: 0.35; outline: 1px dashed #9ecbff; outline-offset: 3px; }

/* Outline everything that's labeled */
.is-code-view main .tagged {
  position: relative;
  outline: 1px dashed rgba(158, 203, 255, 0.4);
  outline-offset: 3px;
}
.is-code-view main :is(section, header, footer, nav).tagged {
  outline: 1px solid rgba(232, 138, 120, 0.5);
  outline-offset: -1px;
}

.is-code-view .code-tag {
  display: block;
  position: absolute; top: 0; left: 0;
  transform: translateY(calc(-100% - 3px));
  z-index: 2;
  padding: 0 0.35rem;
  font: 600 0.65rem/1.5 var(--mono);
  font-style: normal; letter-spacing: 0; text-transform: none; text-decoration: none;
  white-space: nowrap;
  color: #1e2227;
  background: #9ecbff;
  border-radius: 2px 2px 0 0;
  pointer-events: none;
}
.is-code-view :is(section, header, footer, nav).tagged > .code-tag {
  transform: none; background: #e88a78; border-radius: 0 0 2px 0;
}
.is-code-view :is(h1, h2, h3).tagged > .code-tag { background: #c3a6ff; }

/* The note at the bottom of the screen */
.code-view-note {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 50;
  max-width: 36rem; margin: 0 auto;
  display: flex; gap: 1rem; align-items: center;
  padding: 0.85rem 1rem;
  font-family: var(--sans); font-size: 0.9rem; line-height: 1.45;
  color: #eceef0; background: #1e2227;
  border: 1px solid #9ecbff; border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.35);
}
.code-view-note[hidden] { display: none; }
.code-view-note p { margin: 0; }
.code-view-note button {
  flex: none;
  font: 600 0.85rem/1 var(--sans);
  color: #1e2227; background: #9ecbff;
  border: 0; border-radius: 0.3rem;
  padding: 0.5rem 0.75rem; cursor: pointer;
}
.code-view-note button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .is-code-view main { transition: none; }
}
@media (max-width: 40rem) {
  .code-view-note { flex-direction: column; align-items: flex-start; }
}