/* =========================================================
   PANCARTA · Espacio de Diálogo Público (PWA)
   Estética Brutalista · Mínima Información · Máx 99 Caracteres
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Anton&family=Archivo+Black&family=Space+Grotesk:wght@400;600;700;900&display=swap');

:root {
  --font-display: 'Archivo Black', 'Anton', -apple-system, sans-serif;
  --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --border-w: 3px;
  --shadow-off: 5px;
}

:root[data-theme="day"] {
  --ink: #000000;
  --paper: #ffffff;
  --paper-alt: #f4f4f4;
  --muted: #666666;
  --border: #000000;
  --shadow: #000000;
  --logo-filter: none;
}

:root[data-theme="night"] {
  --ink: #ffffff;
  --paper: #080808;
  --paper-alt: #141414;
  --muted: #999999;
  --border: #ffffff;
  --shadow: #ffffff;
  --logo-filter: invert(1) hue-rotate(180deg);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.35;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.pancarta-shell {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  border-left: var(--border-w) solid var(--border);
  border-right: var(--border-w) solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

@media (max-width: 680px) {
  .pancarta-shell {
    border-left: none;
    border-right: none;
  }
}

/* Cabecera Brutalista */
.pancarta-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: var(--border-w) solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-scroll-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  filter: var(--logo-filter);
}

.brand-text-block {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.5px;
  line-height: 1;
  text-transform: uppercase;
}

.brand-sub {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-brutal {
  border: var(--border-w) solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  padding: 7px 12px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
}

.btn-brutal:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--shadow);
}

.btn-brutal:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn-brutal.primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-brutal.small {
  padding: 4px 9px;
  font-size: 0.7rem;
  box-shadow: 2px 2px 0 var(--shadow);
}

/* Barra de instalación / Estado PWA */
.pwa-install-banner {
  border-bottom: var(--border-w) solid var(--border);
  background: var(--paper-alt);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pwa-install-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 200px;
}

.pwa-install-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  text-transform: uppercase;
}

.pwa-install-desc {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

/* Barra de usuario activo */
.user-session-bar {
  border-bottom: 2px dashed var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--paper);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.user-dot {
  width: 8px;
  height: 8px;
  background: var(--ink);
  display: inline-block;
}

/* Caja de publicación principal (99 caracteres) */
.composer-section {
  border-bottom: var(--border-w) solid var(--border);
  padding: 16px;
  background: var(--paper);
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-input-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.composer-input {
  flex: 1;
  min-width: 0;
  border: var(--border-w) solid var(--border);
  background: var(--paper);
  color: var(--ink);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  outline: none;
}

.composer-input:focus {
  box-shadow: inset 3px 3px 0 var(--shadow);
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

/* Bloque de aviso cuando no se ha instalado / iniciado sesión */
.readonly-notice-box {
  border-bottom: var(--border-w) solid var(--border);
  padding: 16px;
  background: var(--paper-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.readonly-notice-box p {
  font-size: 0.84rem;
  font-weight: 700;
}

.readonly-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Muro de mensajes */
.wall-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wall-toolbar {
  padding: 8px 16px;
  border-bottom: 2px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--paper-alt);
}

.messages-list {
  display: flex;
  flex-direction: column;
}

/* Tarjeta de Mensaje Brutalista */
.msg-item {
  border-bottom: var(--border-w) solid var(--border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--paper);
}

.msg-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
}

.msg-author {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.msg-date {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: monospace;
}

.msg-text {
  font-size: 1.02rem;
  font-weight: 700;
  word-break: break-word;
  line-height: 1.35;
  padding: 2px 0;
}

/* Respuestas encadenadas */
.msg-replies {
  margin-top: 4px;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reply-item {
  background: var(--paper-alt);
  border: 2px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reply-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 0.72rem;
  border-bottom: 1px dotted var(--border);
  padding-bottom: 2px;
}

.reply-author {
  font-family: var(--font-display);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.reply-target {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
}

.reply-date {
  font-size: 0.66rem;
  color: var(--muted);
  font-family: monospace;
}

.reply-text {
  font-size: 0.9rem;
  font-weight: 700;
  word-break: break-word;
}

/* Campo para responder debajo de cada mensaje */
.msg-reply-box {
  margin-top: 4px;
  padding-top: 6px;
}

.reply-form {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.reply-input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  outline: none;
}

.reply-input:focus {
  box-shadow: inset 2px 2px 0 var(--shadow);
}

.reply-input[disabled] {
  background: var(--paper-alt);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.75;
}

.btn-reply-submit {
  border: 2px solid var(--border);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.72rem;
  text-transform: uppercase;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
  white-space: nowrap;
}

.btn-reply-submit:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.btn-reply-submit[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Modales de Instalación (Registro Usuario + PIN) y Acceso */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-w) solid var(--border);
  box-shadow: 8px 8px 0 var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal-card-header {
  padding: 12px 16px;
  border-bottom: var(--border-w) solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  text-transform: uppercase;
}

.modal-close {
  border: 2px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  width: 30px;
  height: 30px;
  font-family: var(--font-display);
  font-size: 1rem;
  cursor: pointer;
}

.modal-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field-input {
  border: var(--border-w) solid var(--border);
  background: var(--paper);
  color: var(--ink);
  padding: 10px 12px;
  font-family: var(--font-display);
  font-size: 1rem;
  outline: none;
  text-transform: uppercase;
}

.field-input.pin-input {
  letter-spacing: 8px;
  text-align: center;
  font-size: 1.25rem;
}

.field-hint {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
}

.error-box {
  border: 2px solid var(--border);
  background: var(--ink);
  color: var(--paper);
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  display: none;
}

/* Toast Brutalista */
.toast-box {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--ink);
  color: var(--paper);
  border: var(--border-w) solid var(--paper);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  display: none;
}
