/* Лаборатория влияния — CASTDEV0926 visual Op8
   Palette: deep brown / pale cream / forest green
   No CDN, no Google Fonts */

:root {
  --bg: #221302;
  --bg-elevated: rgba(249, 252, 186, 0.06);
  --bg-field: rgba(249, 252, 186, 0.08);
  --ink: #f9fcba;
  --ink-muted: #d6d99a;
  --ink-soft: #b8bb7e;
  /* Brand progress #145229 kept as base; fill lightened for ≥3:1 on #221302 */
  --progress-brand: #145229;
  --progress: #1f8a42;
  --progress-track: rgba(249, 252, 186, 0.22);
  --hover-bg: #2ecc71;
  --hover-accent: #ff5f5f;
  /* Hover text uses dark ink on green (coral-on-green was ~1.4:1) */
  --hover-text: #221302;
  --error: #ff8a7a;
  --focus: #f9fcba;
  --border: rgba(249, 252, 186, 0.55);
  --border-soft: rgba(249, 252, 186, 0.28);
  --radius: 2px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --font-display: "Palatino Linotype", Palatino, "Book Antiqua", "Iowan Old Style",
    "Times New Roman", serif;
  --font: "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji";
  --motion: 280ms;
  --max: 1180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 85% 8%, rgba(20, 82, 41, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 45% at 8% 20%, rgba(249, 252, 186, 0.06), transparent 50%),
    linear-gradient(165deg, #2a1a08 0%, var(--bg) 42%, #1a0f02 100%);
  background-attachment: fixed;
}

a {
  color: var(--ink);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.1rem 1.35rem 2rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0 1.1rem;
}

.brand {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}

.brand--hero {
  font-size: 0.78rem;
  margin-bottom: 1.15rem;
  color: var(--ink-soft);
}

.site-logo {
  display: block;
  flex: 0 0 auto;
  line-height: 0;
}

.site-logo__img {
  display: block;
  width: clamp(7.5rem, 16vw, 10.5rem);
  height: auto;
  /* Source asset is white/gray; tint toward brand cream #F9FCBA */
  filter: brightness(0) saturate(100%) invert(97%) sepia(18%) saturate(620%)
    hue-rotate(8deg) brightness(104%) contrast(96%);
}

.app {
  flex: 1;
  position: relative;
}

.screen {
  display: none;
}

.screen--active {
  display: block;
  opacity: 1;
  transform: none;
  animation: screen-in var(--motion) ease both;
}

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

.screen.is-leaving {
  display: block;
  animation: screen-out 220ms ease both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes screen-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    /* Keep residual opacity to avoid a full dark-frame flash between screens */
    opacity: 0.2;
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion: 1ms;
  }

  .screen--active,
  .screen.is-leaving {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .btn,
  .media__img {
    transition: none !important;
  }
}

/* Intro — two columns, hero right */
.intro-layout {
  display: grid;
  gap: 1.75rem;
  align-items: center;
  padding: 0.35rem 0 1rem;
}

.intro {
  max-width: 36rem;
  padding: 0.5rem 0 0.25rem;
}

.intro__title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3.2vw, 2.2rem);
  line-height: 1.22;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.intro__subtitle {
  margin: 0 0 1.15rem;
  font-size: 1.12rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.intro__text {
  margin: 0 0 1.15rem;
  color: var(--ink);
  max-width: 32rem;
}

.intro__anon {
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--ink);
}

.intro__note {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.intro-visual {
  min-width: 0;
}

.actions--intro {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
}

.share-status {
  margin: 0.85rem 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.share-status--url {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  max-width: 100%;
}

.share-status__url {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-field);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

/* Media frames — part of one composition, not a competing card */
.media {
  margin: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.media--hero {
  aspect-ratio: 16 / 9;
  width: 100%;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
  background: var(--bg-elevated);
}

.media--question {
  aspect-ratio: 16 / 9;
  width: 100%;
  border: 1px solid rgba(249, 252, 186, 0.18);
}

.media__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 700ms ease;
}

.media:hover .media__img {
  transform: scale(1.02);
}

/* Question layout — ~65% form / ~35% visual desktop */
.question-layout {
  display: grid;
  gap: 1.5rem;
  align-items: start;
  padding: 0.35rem 0 1rem;
}

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

.progress {
  margin: 0 0 1.2rem;
}

.progress__label {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.progress__track {
  display: block;
  height: 3px;
  background: var(--progress-track);
  border-radius: 1px;
  overflow: hidden;
}

.progress__fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--progress-brand), var(--progress));
  box-shadow: 0 0 0 1px rgba(31, 138, 66, 0.45);
}

.question__title {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  line-height: 1.3;
  color: var(--ink);
  font-weight: 650;
}

.question__hint {
  margin: 0 0 1.35rem;
  color: var(--ink-muted);
  font-size: 1rem;
  max-width: 40rem;
}

.field {
  margin-bottom: 1.5rem;
}

.field__label {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field__input {
  display: block;
  width: 100%;
  min-height: 9.5rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-field);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.field__input::placeholder {
  color: var(--ink-soft);
  opacity: 0.85;
}

.field__input:hover {
  border-color: var(--ink);
  background: rgba(249, 252, 186, 0.1);
}

.field__input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(249, 252, 186, 0.2);
  background: rgba(249, 252, 186, 0.11);
}

.field__input.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(255, 138, 122, 0.25);
}

.field__error {
  margin: 0.55rem 0 0;
  color: var(--error);
  font-size: 0.92rem;
}

.submit-status {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: rgba(20, 82, 41, 0.28);
  border: 1px solid rgba(46, 204, 113, 0.45);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 0.98rem;
}

.question-visual {
  min-width: 0;
}

.visual {
  color: var(--ink);
}

/* Actions / buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.actions--split {
  justify-content: space-between;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: 1rem;
  font-weight: 560;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease,
    transform 160ms ease;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.btn--primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.btn--primary:hover {
  background: var(--hover-bg);
  border-color: var(--hover-accent);
  color: var(--hover-text);
}

.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
  font-weight: 500;
  min-height: 2.55rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
}

.btn--secondary:hover {
  border-color: var(--hover-accent);
  color: var(--hover-accent);
  background: rgba(46, 204, 113, 0.12);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: transparent;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.btn--ghost:hover {
  color: var(--ink);
}

/* Success / error panels (prepared, not shown now) */
.final-panel {
  max-width: 34rem;
  padding: 2rem 0 1rem;
}

.final-panel__title {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  color: var(--ink);
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.final-panel__lead {
  margin: 0 0 1rem;
  font-weight: 600;
  color: var(--ink);
}

.final-panel__text {
  margin: 0 0 1.25rem;
  color: var(--ink-muted);
}

.final-panel__sign {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.final-panel__note {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.site-footer {
  margin-top: 2.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.site-footer p {
  margin: 0;
}

.footer-link {
  color: var(--ink-muted);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.admin-entry {
  margin: 0;
}

.admin-entry__link {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Desktop compositions */
@media (min-width: 900px) {
  .intro-layout {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 2.75rem;
    min-height: 28rem;
  }

  /* Desktop Q1–Q4: text ALWAYS left, image ALWAYS right (no chess layout) */
  .question-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 2.35rem;
    min-height: 28rem;
  }

  .question-main {
    order: 1;
  }

  .question-visual {
    order: 2;
    padding-top: 2.35rem;
  }
}

/* Mobile: rethink stacking, not just shrink */
@media (max-width: 899px) {
  .site-header {
    align-items: flex-start;
  }

  .intro-layout {
    gap: 1.35rem;
  }

  /* Atmosphere first, then copy + CTA */
  .intro-visual {
    order: -1;
  }

  .media--hero {
    max-height: 42vw;
    min-height: 9.5rem;
  }

  /* Mobile: progress → title+hint together → image → field → actions
     Image must NOT split title from hint. */
  .question-layout {
    grid-template-columns: 1fr;
  }

  .question-main {
    display: contents;
  }

  .question-main > .progress {
    order: 1;
  }

  .question-main > .question__title {
    order: 2;
  }

  .question-main > .question__hint {
    order: 3;
  }

  .question-visual {
    order: 4;
    margin: 0.15rem 0 0.35rem;
  }

  .question-main > .field,
  .question-main > .submit-status,
  .question-main > .actions {
    order: 5;
  }

  .media--question {
    max-height: 9.5rem;
  }

  .admin-entry {
    width: 100%;
    margin-top: 0.35rem;
  }

  .actions--intro {
    width: 100%;
  }

  .actions--intro .btn {
    width: 100%;
  }
}

@media (max-width: 374px) {
  .page {
    padding: 0.9rem 0.9rem 1.5rem;
  }

  .field__input {
    min-height: 8.5rem;
  }

  .actions--split {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .btn--ghost {
    justify-content: flex-start;
  }

  .media--question {
    max-height: 8rem;
  }
}
