/* ════════════════════════════════════════════════════
   BARSIGN — Farm Country Theme
   ════════════════════════════════════════════════════ */

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

:root {
  --open-color: #27ae60;
  --open-glow: #2ecc71;
  --closed-color: #c0392b;
  --closed-glow: #e74c3c;
  --wood-dark: #4a2c0a;
  --wood-mid: #6b3d12;
  --wood-light: #8b5e2a;
  --wood-grain: #7a4f1c;
  --cream: #f5e6c8;
  --text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
  --sign-width: min(520px, 92vw);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Rye', serif;
  background: #1a6fa8;
}

/* ── Scene / Background ─────────────────────────── */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.farm-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.bg-overlay {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.5s;
}

.bg-overlay.loaded {
  opacity: 1;
}

/* ── Sign wrapper ────────────────────────────────── */
.sign-wrapper {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ── Hanging chain ───────────────────────────────── */
.chain-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: -4px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.chain-link {
  display: block;
  width: 28px;
  height: 14px;
  border: 4px solid #888;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.3);
}

/* ── Wooden Sign ─────────────────────────────────── */
.sign {
  width: var(--sign-width);
  background:
    /* Grain texture lines */
    repeating-linear-gradient(
      180deg,
      transparent,
      transparent 18px,
      rgba(0,0,0,0.06) 18px,
      rgba(0,0,0,0.06) 20px
    ),
    /* Wood color base */
    linear-gradient(
      160deg,
      var(--wood-light) 0%,
      var(--wood-mid) 30%,
      var(--wood-dark) 60%,
      var(--wood-grain) 80%,
      var(--wood-mid) 100%
    );
  border: 6px solid var(--wood-dark);
  border-radius: 8px;
  padding: 28px 36px 22px;
  box-shadow:
    0 12px 40px rgba(0,0,0,0.6),
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 2px 6px rgba(255,255,255,0.1),
    inset 0 -2px 6px rgba(0,0,0,0.3);
  position: relative;
  text-align: center;

  /* Nail decorations */
}

.sign::before,
.sign::after {
  content: '';
  position: absolute;
  top: 14px;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 35% 35%, #ccc, #777);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.sign::before { left: 16px; }
.sign::after  { right: 16px; }

/* ── Sign header ─────────────────────────────────── */
.sign-header {
  margin-bottom: 16px;
}

.sign-name {
  font-family: 'Rye', serif;
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  color: var(--cream);
  text-shadow:
    var(--text-shadow),
    0 0 30px rgba(255,220,100,0.4);
  letter-spacing: 0.06em;
  line-height: 1.1;
}

.sign-subtitle {
  font-family: 'Playfair Display', serif;
  font-size: clamp(0.65rem, 2vw, 0.85rem);
  color: #c9a96a;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Divider ─────────────────────────────────────── */
.sign-divider {
  height: 3px;
  background: linear-gradient(90deg, transparent, #c9a96a 20%, #c9a96a 80%, transparent);
  margin: 14px 0;
  border-radius: 2px;
}

/* ── Status section ──────────────────────────────── */
.status-section {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0 16px;
}

.status-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.6s, background 0.6s;
  pointer-events: none;
  filter: blur(40px);
}

.status-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(160px, 40vw, 220px);
  height: clamp(160px, 40vw, 220px);
  border-radius: 50%;
  border: 8px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.08),
    inset 0 4px 12px rgba(0,0,0,0.4);
  transition: background 0.5s, box-shadow 0.5s, border-color 0.5s;
}

.status-text {
  font-family: 'Rye', serif;
  font-size: clamp(1.6rem, 8vw, 3rem);
  font-weight: normal;
  letter-spacing: 0.08em;
  color: #ccc;
  transition: color 0.5s, text-shadow 0.5s;
  text-shadow: var(--text-shadow);
}

/* OPEN state */
.sign.is-open .status-badge {
  background: radial-gradient(circle, #27ae60dd 0%, #1a7a43aa 60%, rgba(0,0,0,0.3) 100%);
  border-color: var(--open-glow);
  box-shadow:
    0 0 0 4px rgba(46,204,113,0.25),
    0 0 40px rgba(46,204,113,0.3),
    inset 0 4px 12px rgba(0,0,0,0.3);
}

.sign.is-open .status-text {
  color: #d4ffd4;
  text-shadow: 0 0 20px rgba(46,204,113,0.8), var(--text-shadow);
}

.sign.is-open .status-glow {
  background: radial-gradient(circle, rgba(46,204,113,0.6), transparent 70%);
  opacity: 1;
  animation: pulse-open 2.5s ease-in-out infinite;
}

/* CLOSED state */
.sign.is-closed .status-badge {
  background: radial-gradient(circle, #c0392bdd 0%, #8b1a1aaa 60%, rgba(0,0,0,0.3) 100%);
  border-color: var(--closed-glow);
  box-shadow:
    0 0 0 4px rgba(231,76,60,0.2),
    0 0 20px rgba(231,76,60,0.15),
    inset 0 4px 12px rgba(0,0,0,0.4);
}

.sign.is-closed .status-text {
  color: #ffd4d4;
  text-shadow: 0 0 16px rgba(231,76,60,0.6), var(--text-shadow);
}

/* LOADING state */
.sign.is-loading .status-text {
  color: #aaa;
  animation: blink 1.2s ease-in-out infinite;
}

/* ── Sign footer ─────────────────────────────────── */
.sign-footer {
  margin-top: 14px;
  font-family: 'Playfair Display', serif;
  font-size: clamp(0.6rem, 1.8vw, 0.78rem);
  color: #b8945a;
  letter-spacing: 0.1em;
}

.updated-time {
  color: #c9a96a;
}

/* ── Connection status dot ───────────────────────── */
.connection-status {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Playfair Display', serif;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  letter-spacing: 0.05em;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
  transition: background 0.4s;
}

.dot.live  { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.dot.error { background: #e74c3c; }
.dot.poll  { background: #f39c12; }

/* ── Animations ──────────────────────────────────── */
@keyframes pulse-open {
  0%, 100% { transform: scale(1);   opacity: 0.8; }
  50%       { transform: scale(1.12); opacity: 1; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Responsive tweaks ───────────────────────────── */
@media (max-height: 600px) {
  .sign {
    padding: 18px 28px 16px;
  }
  .chain-bar { display: none; }
  .status-section { padding: 12px 0 10px; }
}

@media (max-width: 380px) {
  :root {
    --sign-width: 96vw;
  }
  .sign {
    padding: 18px 20px 16px;
  }
}
