/* ============================================================
   SteamEngine15 – Main Stylesheet
   ============================================================ */

:root {
  --se15-copper:     #b87333;
  --se15-brass:      #c8a84b;
  --se15-dark-metal: #1a1a1a;
  --se15-steam-col:  #c8c8c8;
  --se15-glow:       rgba(200,168,75,0.35);
  --se15-bg:         #0e0b08;
  --se15-rivet:      #8a7a5a;
  --se15-glass:      rgba(40,55,70,0.55);
  --se15-glass-rim:  #7a6030;
}

/* ── Widget Shell ── */
.steam-engine-15-widget {
  position:   relative;
  width:      100%;
  overflow:   hidden;
  background: var(--se15-bg);
  border:     3px solid var(--se15-brass);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(0,0,0,0.8), inset 0 0 60px rgba(0,0,0,0.6);
  touch-action: none;
  user-select: none;
  font-family: 'Georgia', serif;
}

/* ── Canvases ── */
.se15-steam-canvas,
.se15-gear-canvas {
  position: absolute;
  top:    0;
  left:   0;
  width:  100%;
  height: 100%;
  pointer-events: none;
}

.se15-steam-canvas { z-index: 30; }
.se15-gear-canvas  { z-index: 10; }

/* ── Machine Wrapper (SVG host) ── */
.se15-machine-wrapper {
  position:   absolute;
  top:        0; left: 0;
  width:      100%; height: 100%;
  display:    flex;
  align-items:   center;
  justify-content: center;
  z-index: 15;
  transition: transform 0.1s ease-out;
}

.se15-machine-wrapper svg {
  width:  100%;
  height: 100%;
}

/* ── Porthole / Glasluke ── */
.se15-porthole-group {
  cursor: pointer;
  transition: filter 0.4s ease;
}

.se15-porthole-group:hover .se15-porthole-frame {
  filter: drop-shadow(0 0 12px var(--se15-brass));
}

.se15-porthole-media {
  filter: blur(8px) brightness(0.4);
  transition: filter 1.2s ease;
}

.se15-porthole-media.se15-focused {
  filter: blur(0px) brightness(1);
}

/* ── Lever Button ── */
.se15-lever-btn {
  position:   absolute;
  bottom:     12%;
  right:      8%;
  width:      48px;
  height:     120px;
  background: transparent;
  border:     none;
  cursor:     pointer;
  z-index:    40;
  display:    flex;
  flex-direction: column;
  align-items:    center;
  padding:    0;
}

.se15-lever-shaft {
  display:      block;
  width:        10px;
  height:       90px;
  background:   linear-gradient(180deg, #999 0%, var(--se15-copper) 50%, #555 100%);
  border-radius: 5px;
  box-shadow:   2px 2px 6px rgba(0,0,0,0.6);
  transform-origin: bottom center;
  transition:   transform 0.5s cubic-bezier(.68,-0.55,.27,1.55);
}

.se15-lever-handle {
  display:      block;
  width:        30px;
  height:       30px;
  background:   radial-gradient(circle at 40% 35%, var(--se15-brass), var(--se15-copper) 60%, #6b3a1f);
  border-radius: 50%;
  border:       2px solid #8a6010;
  box-shadow:   0 0 12px var(--se15-glow), inset 0 2px 4px rgba(255,255,255,0.2);
  margin-top:   4px;
}

.se15-lever-btn.se15-active .se15-lever-shaft {
  transform: rotate(40deg);
}

/* ── Pressure gauge decorative ── */
.se15-gauge-needle {
  transform-origin: 50% 90%;
  transition: transform 1s ease-in-out;
}

/* ── Piston / Connecting rod ── */
@keyframes se15-piston {
  0%   { transform: translateX(0);   }
  50%  { transform: translateX(22px); }
  100% { transform: translateX(0);   }
}

.se15-piston-rod {
  animation: none;
}

.se15-running .se15-piston-rod {
  animation: se15-piston 0.8s ease-in-out infinite;
}

/* ── Smoke pipe animation ── */
@keyframes se15-pipe-smoke {
  0%   { opacity: 0;   transform: translateY(0)   scale(0.6); }
  30%  { opacity: 0.7; }
  100% { opacity: 0;   transform: translateY(-60px) scale(2); }
}

.se15-pipe-smoke {
  animation: se15-pipe-smoke 1.6s ease-out infinite;
}

.se15-pipe-smoke:nth-child(2) { animation-delay: 0.5s; }
.se15-pipe-smoke:nth-child(3) { animation-delay: 1.1s; }

/* ── Status light ── */
.se15-status-light {
  transition: fill 0.5s ease, filter 0.5s ease;
}

.se15-running .se15-status-light {
  fill:   #00ff88;
  filter: drop-shadow(0 0 6px #00ff88);
}

/* ── Lightbox Overlay ── */
.se15-lightbox-overlay {
  position:   fixed;
  top:        0; left: 0;
  width:      100vw; height: 100vh;
  z-index:    99999;
  display:    flex;
  align-items:   center;
  justify-content: center;
  background: rgba(5,3,1,0.0);
  opacity:    0;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.4s ease;
}

.se15-lightbox-overlay.se15-lb-open {
  opacity:    1;
  pointer-events: all;
  background: rgba(5,3,1,0.93);
}

/* ── Lightbox Inner ── */
.se15-lightbox-inner {
  position:  relative;
  max-width: 90vw;
  max-height: 88vh;
  width:     900px;
  background: #100d0a;
  border:    3px solid var(--se15-brass);
  border-radius: 6px;
  overflow:  hidden;
  box-shadow: 0 0 80px rgba(200,168,75,0.3), inset 0 0 40px rgba(0,0,0,0.8);
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
}

.se15-lightbox-overlay.se15-lb-open .se15-lightbox-inner {
  transform: scale(1);
}

/* ── LB Close button ── */
.se15-lightbox-close {
  position:   absolute;
  top:        12px; right: 16px;
  z-index:    10;
  background: var(--se15-dark-metal);
  border:     2px solid var(--se15-brass);
  color:      var(--se15-brass);
  font-size:  24px;
  line-height: 1;
  width:      36px; height: 36px;
  border-radius: 50%;
  cursor:     pointer;
  display:    flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.se15-lightbox-close:hover {
  background: var(--se15-brass);
  color:      #100d0a;
}

/* ── LB Steam canvas ── */
.se15-lb-steam-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ── LB Media ── */
.se15-lb-media {
  position:  relative;
  z-index:   4;
  width:     100%;
  display:   flex;
  align-items:   center;
  justify-content: center;
  padding:   48px 24px 24px;
}

.se15-lb-media img,
.se15-lb-media video {
  max-width:  100%;
  max-height: 70vh;
  border:     3px solid var(--se15-brass);
  border-radius: 4px;
  box-shadow: 0 0 30px rgba(0,0,0,0.7);
}

/* ── LB Decorative Pipes ── */
.se15-lb-pipes {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.se15-lb-pipe {
  position: absolute;
  background: linear-gradient(90deg, var(--se15-copper), var(--se15-brass), var(--se15-copper));
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

/* ── Rivets ── */
.se15-rivet {
  fill:   var(--se15-rivet);
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .se15-side-gears,
  .se15-top-machinery {
    display: none;
  }

  .se15-lever-btn {
    right:  4%;
    bottom: 8%;
    height: 80px;
  }

  .se15-lever-shaft { height: 60px; }

  .se15-lightbox-inner {
    width:  95vw;
    max-height: 90vh;
  }
}

/* ── Gear rotation (JS drives transform) ── */
.se15-gear {
  transform-origin: center;
  will-change: transform;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .se15-pipe-smoke,
  .se15-piston-rod { animation: none !important; }
}

/* ── Industrial panel texture overlay ── */
.se15-panel-overlay {
  position:   absolute;
  top:        0; left: 0;
  width:      100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.04) 2px,
    rgba(0,0,0,0.04) 4px
  );
  pointer-events: none;
  z-index: 50;
}
