:root {
  --bg-1: #2f2f2b;
  --bg-2: #3a3a35;
  --bar-1: #d9d9d9;
  --bar-2: #bdbdbd;
  --bar-edge: #8b8b8b;
  --text: #1d1d1d;
  --accent: #1e6acb;
  --panel: #e0e0e0;
  --panel-edge: #9a9a9a;
  --shadow: rgba(0, 0, 0, 0.45);
  --line-y: 55vh;
  --bar-h: 50px;
  --bar-half: 25px;
  --panel-gap: 4px;
  --panel-drop: 36px;
  --panel-safe: 28px;
  --offset-active: -56px;
  --offset-1: 52px;
  --offset-2: 116px;
  --logo-x: 30vw;
  --panel-x: 60vw;
  --dock-gap: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #111;
  background: #2f2f2b;
  height: 100vh;
  overflow: hidden;
}

.is-loaded * {
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(
    120% 120% at 20% 10%,
    #42423c 0%,
    #2f2f2b 45%,
    #2b2b27 100%
  );
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 2px
  );
  mix-blend-mode: overlay;
}

.bars {
  position: fixed;
  z-index: 1;
  width: 100%;
  left: 0;
  right: 0;
  margin: 0;
  top: calc(var(--line-y) - var(--bar-half));
}

.bar {
  height: var(--bar-h);
  background: linear-gradient(180deg, var(--bar-1), var(--bar-2));
  border-top: 1px solid #f3f3f3;
  border-bottom: 1px solid var(--bar-edge);
  box-shadow: 0 2px 6px var(--shadow);
  display: flex;
  align-items: center;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  overflow: visible; /* Allow dock buttons to peek out if raised */
  transition:
    transform 360ms ease,
    opacity 360ms ease;
}

.current-bar {
  position: relative;
  z-index: 2;
  transform: scaleX(0) translateY(var(--bar-nudge, 0px));
  transition:
    transform 360ms ease,
    opacity 360ms ease;
}
.is-loaded .bar {
  opacity: 1;
}
.is-loaded .bar:not(.current-bar) {
  transform: scaleX(1);
}
.is-loaded .current-bar {
  transform: scaleX(1) translateY(var(--bar-nudge, 0px));
}

.watermark {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 60%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
  mix-blend-mode: overlay;
}

.watermark img {
  width: 100%;
  height: auto;
  display: block;
}

.brand {
  position: absolute;
  left: var(--logo-x);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  transition: all 0.4s ease;
  z-index: 10;
}

/* Smart positioning: when minimized/shifted */
.brand.is-shifted {
  left: 40px;
  transform: translateY(-50%) scale(0.8);
}

.brand img {
  max-width: 200px;
  height: auto;
}

.dock {
  position: fixed;
  left: var(--dock-left, calc(var(--logo-x) + 220px));
  top: 0;
  width: 52px;
  height: 100vh;
  z-index: 100; /* Ensure always above panels */
  pointer-events: none; /* Let clicks pass through container, but buttons capture them */
}

.dock-btn {
  /* ... keep existing ... */
  pointer-events: auto; /* Enable clicks on buttons */
  z-index: 101;
}

.dock-btn {
  position: fixed;
  left: var(--dock-left, calc(var(--logo-x) + 220px));
  top: calc(var(--line-y) + var(--offset, 0px) - 26px);
  width: 52px;
  height: 52px;
  border-radius: 6px;
  border: 1px solid #666;
  background: linear-gradient(180deg, #e4e4e4, #c9c9c9);
  box-shadow:
    inset 0 1px 0 #fff,
    0 2px 4px rgba(0, 0, 0, 0.35);
  font-size: 30px;
  font-weight: 700;
  color: #333;
  cursor: pointer;
  opacity: 0;
  transform: translateY(0);
  transition:
    top 280ms ease,
    transform 120ms ease,
    box-shadow 120ms ease,
    opacity 220ms ease;
}

.dock-btn:hover {
  transform: translateY(-4px);
  box-shadow:
    inset 0 1px 0 #fff,
    0 4px 8px rgba(0, 0, 0, 0.35);
}

.dock-btn.is-active:hover {
  transform: translateY(-6px);
}

.is-loaded .dock-btn {
  opacity: 1;
  transform: translateY(0);
}

.dock-btn:nth-child(1) {
  transition-delay: 220ms;
}
.dock-btn:nth-child(2) {
  transition-delay: 280ms;
}
.dock-btn:nth-child(3) {
  transition-delay: 340ms;
}

.panel {
  position: absolute;
  left: var(--panel-x);
  top: 50%;
  width: 430px;
  padding: 40px 30px;
  background: rgba(47, 47, 43, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  color: #dedede;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition:
    opacity 240ms ease,
    transform 240ms ease;
  display: none;
  z-index: 20;
  max-height: calc(
    var(--line-y) - var(--bar-half) - var(--panel-gap) - var(--panel-safe)
  );
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.panel.is-shown {
  opacity: 1 !important;
  transform: translate(-50%, 0) !important;
  /* display is handled by JS inline styles mostly, but ensure block if not */
}

#projects.panel {
  height: 80vh;
  max-height: 80vh;
  padding-top: 60px; /* Increased padding */
  overflow-y: scroll; /* Always show scrollbar */
  top: 50%;
  transform: translate(-50%, -50%); /* Center vertically */
}
/* Ensure the JS positioning doesn't override this too aggressively, 
   or we might need !important if JS sets inline styles for top/max-height. 
   The JS `positionPanel` sets top and max-height. 
   We might need to adjust JS or use !important here. 
   User said "La pantalla de proyectos necesitamso que sea del 80% de alto".
   Let's try !important for height constraints to override JS calculation if needed, 
   but JS calculation `positionPanel` is smart. 
   However, user wants fixed 80%. 
   I will add !important to be safe against the inline JS styles. */
#projects.panel {
  height: 80vh !important;
  max-height: 80vh !important;
  padding-top: 60px;
  overflow-y: scroll;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}

.panel-right {
  left: var(--panel-x);
  top: calc(var(--line-y) - var(--panel-gap) + var(--panel-drop));
  width: 430px;
  display: none;
  z-index: 20;
}

.panel-head {
  font-weight: 700;
  margin-bottom: 8px;
}

.panel-quote {
  font-style: italic;
}

.clean {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.clean li {
  margin: 6px 0;
}

.panel-gallery {
  display: grid;
  gap: 22px;
  justify-items: center;
  text-align: center;
  align-content: center;
}

.project {
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
  padding: 4px 0;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 240ms ease,
    transform 240ms ease;
}

.project-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 70px;
  background: transparent;
}

.project-logo img {
  max-width: 260px;
  max-height: 110px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.project-link {
  font-size: 12px;
  letter-spacing: 0.4px;
  color: #88c0d0; /* Accent color for links */
  text-decoration: none;
}

.project-link:hover {
  text-decoration: underline;
  color: #fff;
}

.project-title {
  font-weight: 700;
  color: #fff;
}

.project-desc {
  font-size: 12px;
  color: #ccc;
}

.project-meta {
  font-size: 11px;
  color: #aaa;
}

.is-loaded .project {
  opacity: 1;
  transform: translateY(0);
}

.project:nth-child(1) {
  transition-delay: 520ms;
}
.project:nth-child(2) {
  transition-delay: 600ms;
}
.project:nth-child(3) {
  transition-delay: 680ms;
}

.card {
  background: #d9d9d9;
  border: 1px solid #8c8c8c;
  box-shadow: 0 3px 8px var(--shadow);
  padding: 10px 12px 12px;
  position: relative;
  opacity: 0;
  transform: translateX(12px);
  transition:
    opacity 240ms ease,
    transform 240ms ease;
}

.card-title {
  font-weight: 700;
  color: #1f1f1f;
  margin-bottom: 2px;
}

.card-row {
  background: #ececec;
  border: 1px solid #bdbdbd;
  padding: 4px 6px;
  margin-top: 6px;
  font-size: 12px;
}

.card-meta {
  color: #356db9;
}
.card-link {
  color: #444;
  font-size: 11px;
}
.card-desc {
  font-size: 12px;
}

.card-frame {
  height: 70px;
  margin-top: 8px;
  background: linear-gradient(135deg, #b7b7b7, #ececec);
  border: 1px solid #9a9a9a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-logo {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-linker {
  text-decoration: none;
  color: inherit;
  display: block;
}

.xml-note {
  font-size: 12px;
  color: #444;
  margin-bottom: 8px;
}

.xml-btn {
  padding: 6px 10px;
  border: 1px solid #8d8d8d;
  background: linear-gradient(180deg, #ededed, #cfcfcf);
  cursor: pointer;
  font-family: inherit;
}

.xml-input {
  display: none;
}

.is-loaded .card {
  opacity: 1;
  transform: translateX(0);
}

.card:nth-child(1) {
  transition-delay: 520ms;
}
.card:nth-child(2) {
  transition-delay: 600ms;
}
.card:nth-child(3) {
  transition-delay: 680ms;
}

.contact-form {
  display: grid;
  gap: 8px;
}

.contact-form input,
.contact-form textarea {
  border: 1px solid #c0c0c0;
  padding: 10px 14px;
  font-family: inherit;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #1f1f1f;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(30, 106, 203, 0.15);
}

.contact-form .is-invalid {
  border-color: #b64848;
  box-shadow:
    0 0 0 2px rgba(182, 72, 72, 0.2),
    inset 0 1px 1px rgba(0, 0, 0, 0.06);
}

.contact-form button {
  padding: 12px 16px;
  border: none;
  background: var(--text);
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 13px;
  transition: background 0.2s ease, transform 0.1s ease;
  margin-top: 4px;
}

.contact-form button:hover {
  background: #000;
}

.contact-form button:active {
  transform: translateY(1px);
}

.contact-guard {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  background: rgba(240, 240, 240, 0.5);
  font-size: 13px;
  color: #555;
  margin-top: 4px;
}

.contact-guard input {
  max-width: 140px;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.footer-left {
  position: fixed;
  left: 20px;
  bottom: 18px;
  font-size: 12px;
  color: #d9d9d9;
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-contact {
  display: flex;
  gap: 8px;
  align-items: center;
}

.footer-left a {
  color: #d9d9d9;
  text-decoration: none;
}

.footer-left a:hover {
  text-decoration: underline;
}
.footer-left .sep {
  opacity: 0.6;
}

.wa-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #d9d9d9;
}

.wa-icon svg {
  width: 14px;
  height: 14px;
  fill: #2f2f2b;
}

/* Tablet / Narrow Desktop */
@media (max-width: 1200px) {
  :root { --line-y: 50vh; }
  
  body { overflow: auto; }
  
  .stage { 
      height: auto; 
      padding-bottom: 120px;
      padding-top: 140px; /* Push content down below fixed/sticky header */ 
      position: static; 
  }

  /* Reset Dock to be inside the bar, not a floating pill */
  /* Reset Dock to be fixed at top right on mobile */
  .dock {
    position: fixed;
    top: 14px;
    right: 20px;
    left: auto;
    bottom: auto;
    transform: none;
    width: auto;
    height: auto;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    margin: 0;
    display: flex;
    gap: 10px;
    z-index: 1000;
  }

  .dock-btn {
    position: relative; /* Override desktop fixed */
    top: auto;
    left: auto;
    transform: none !important;
    opacity: 1 !important;
    margin: 0;
    width: 44px;
    height: 44px;
    font-size: 24px;
    box-shadow: none;
    /* meaningful styles for the button in bar */
    border: 1px solid #999;
    background: linear-gradient(180deg, #e4e4e4, #c9c9c9);
  }
  
  .dock-btn:hover {
     transform: translateY(-2px);
  }
  
  /* Brand positioning in the bar */
  .brand {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: auto;
    text-align: left;
    display: block;
    margin-right: 10px;
  }
  
  /* Ensure bar contains them properly */
  .bar {
      justify-content: center; /* Center the group (logo + dock) */
      height: auto;
      padding: 10px 0;
      flex-wrap: wrap;
  }
  
  .panel, .panel-right, .panel-gallery {
     position: relative;
     left: auto;
     top: auto;
     transform: none !important;
     width: 90vw;
     max-width: 600px;
     margin: 40px auto; 
     display: none; 
     height: auto;
     max-height: none;
     overflow: visible;
  }
  
  #projects.panel {
      height: 60vh !important; /* Smaller height on mobile */
      max-height: 60vh !important;
      margin-top: 40px;
      padding-top: 20px;
  }

  .panel.is-shown {
      display: block;
      animation: fadeIn 0.4s ease;
  }
  
  .footer-left {
    position: static;
    justify-content: center;
    padding: 20px 0;
  }
  
  .bars {
      position: relative; /* Stick to normal flow or sticky? User said "siempre se queda por encima" */
      top: 0;
      opacity: 1;
      height: auto;
      margin-bottom: 20px;
      background: #2f2f2b; /* Match bg to cover scrolling content if needed, or transparent? */
      /* Actually, .bars is fixed in main CSS. In mobile, maybe position: sticky top:0? */
      position: sticky;
      top: 0;
      z-index: 500;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .brand img {
      max-width: 150px;
  }

  .dock {
    gap: 8px;
    margin-left: 5px;
  }
  
  .dock-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
  
  .panel, .panel-right, .panel-gallery {
    width: 95vw;
    margin-top: 20px;
  }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.dock-btn.is-active {
  background: linear-gradient(180deg, #d5d5d5, #b9b9b9);
  box-shadow:
    inset 0 1px 0 #f7f7f7,
    0 4px 8px rgba(0, 0, 0, 0.45);
}
