/* Płynne zwężanie i rozszerzanie całego kontekstu oraz ukrywanie/pokazywanie menu bocznego */
:root {
  --sidebar-width: 248px;
}

@media (min-width: 981px) {
  .sidebar {
    top: var(--sidebar-top, 72px);
    bottom: 0;
    padding-top: calc(1.35rem + (0.65rem * (1 - var(--sidebar-scroll-progress, 0))));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
  }

  body:has(.sidebar) .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1), width 0.3s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

body:not(:has(.sidebar)) .main-content {
  margin-left: 0;
  width: 100%;
  max-width: 100%;
}

.php-shell {
  width: min(1200px, calc(100% - 2.5rem));
  max-width: 100%;
  margin: 0 auto;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stan: Menu złożone (ukryte) - pełne rozszerzenie całego kontekstu roboczego */
html.modernizer-sidebar-collapsed .sidebar,
body.modernizer-sidebar-collapsed .sidebar {
  transform: translateX(-105%);
  opacity: 0;
  pointer-events: none;
}

html.modernizer-sidebar-collapsed .main-content,
body.modernizer-sidebar-collapsed .main-content {
  margin-left: 0;
  width: 100%;
  max-width: 100vw;
}

html.modernizer-sidebar-collapsed .php-shell,
body.modernizer-sidebar-collapsed .php-shell {
  width: min(1680px, calc(100% - 3rem));
  max-width: 98vw;
}

/* Płynne, bezpośrednie wyciąganie paska bocznego na menu górne przy przewijaniu */
@media (min-width: 721px) {
  .sidebar {
    background: rgba(8, 17, 31, calc(0.92 + (0.06 * var(--sidebar-scroll-progress, 0)))) !important;
    backdrop-filter: blur(24px) !important;
    box-shadow: calc(4px * var(--sidebar-scroll-progress, 0)) 0 calc(28px * var(--sidebar-scroll-progress, 0)) rgba(0, 0, 0, calc(0.5 * var(--sidebar-scroll-progress, 0))) !important;
  }

  .site-header-brand-row {
    transition: transform 0.2s ease;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* Mała strzałeczka (Edge Toggle Button) na krawędzi paska bocznego */
.sidebar-edge-toggle {
  position: fixed;
  top: var(--sidebar-edge-top, 110px) !important;
  left: var(--sidebar-width);
  z-index: 100;
  width: 28px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f1d2e;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-left: none;
  border-radius: 0 9px 9px 0;
  color: #38bdf8;
  cursor: pointer;
  box-shadow: 3px 2px 14px rgba(0, 0, 0, 0.45);
  transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.sidebar-edge-toggle:hover {
  background: #172a42;
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.8);
  transform: scale(1.06);
}

.edge-arrow-icon {
  font-size: 0.85rem;
  line-height: 1;
  font-weight: 700;
}

html.modernizer-sidebar-collapsed .sidebar-edge-toggle,
body.modernizer-sidebar-collapsed .sidebar-edge-toggle {
  left: 0 !important;
  background: rgba(14, 27, 44, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-left: none;
  box-shadow: 4px 2px 18px rgba(0, 0, 0, 0.6);
}

.modernizer-sidebar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(56, 189, 248, 0.12) !important;
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
  color: #38bdf8 !important;
  font-weight: 700 !important;
}

.modernizer-sidebar-btn:hover {
  background: rgba(56, 189, 248, 0.25) !important;
  color: #ffffff !important;
  border-color: rgba(56, 189, 248, 0.6) !important;
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 220px;
  }
  .sidebar-edge-toggle {
    top: 130px;
  }
}

@media (max-width: 720px) {
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  .sidebar-edge-toggle,
  .modernizer-sidebar-btn {
    display: none !important;
  }
}

/* Apple-Style Modernizer Design */
.apple-hero-section {
  text-align: center;
  margin: 1.5rem 0 2.5rem;
  padding: clamp(2.5rem, 5vw, 4rem) 1.5rem;
  border-radius: 24px;
  background: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.16) 0%, rgba(15, 23, 42, 0) 70%),
              linear-gradient(180deg, rgba(20, 26, 38, 0.95) 0%, rgba(10, 14, 22, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.apple-hero-kicker {
  display: inline-block;
  font: 700 0.75rem/1.2 Consolas, monospace;
  letter-spacing: 0.16em;
  color: #38bdf8;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
}
.apple-hero-title {
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-weight: 800;
  color: #f8fafc;
  margin: 0 0 1.25rem;
}
.apple-hero-gradient {
  background: linear-gradient(135deg, #38bdf8 0%, #4ec9b0 50%, #a7f3d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.apple-hero-lead {
  max-width: 720px;
  margin: 0 auto 2.25rem;
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.65;
  color: #94a3b8;
}
.apple-hero-badges {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.apple-hero-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 0.85rem 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 170px;
  text-align: center;
  transition: all 0.25s ease;
}
.apple-hero-badge:hover {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.05);
  transform: translateY(-2px);
}
.apple-hero-badge .badge-icon {
  font-size: 1.5rem;
  margin-bottom: 0.15rem;
}
.apple-hero-badge strong {
  font-size: 0.95rem;
  color: #f1f5f9;
}
.apple-hero-badge small {
  font-size: 0.78rem;
  color: #94a3b8;
}

/* Apple Segmenter */
.apple-tech-segmenter-wrap {
  display: flex;
  justify-content: center;
  margin: 2.5rem 0 1.5rem;
}
.apple-tech-segmenter {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.35rem;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
.segment-btn {
  padding: 0.55rem 1.3rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.segment-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
}
.segment-btn:focus-visible,
.view-mode-btn:focus-visible,
.sidebar-edge-toggle:focus-visible,
.apple-preset-card:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.7);
  outline-offset: 2px;
}
.segment-btn.is-active {
  background: #38bdf8;
  color: #041320;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.35);
}

/* Apple Preset Cards Grid */
.apple-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.15rem;
  margin-bottom: 2.75rem;
}
.apple-preset-card {
  background: rgba(18, 24, 38, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  padding: 1.35rem 1.4rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-family: inherit;
  position: relative;
}
.apple-preset-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(24, 32, 50, 0.95);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.apple-preset-card.is-active {
  border-color: #4ec9b0;
  background: linear-gradient(135deg, rgba(20, 38, 44, 0.95), rgba(15, 28, 38, 0.98));
  box-shadow: 0 0 0 1px #4ec9b0, 0 12px 35px rgba(78, 201, 176, 0.22);
}
.preset-tag {
  align-self: flex-start;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: Consolas, monospace;
  letter-spacing: 0.05em;
}
.tag-php { background: rgba(147, 51, 234, 0.18); color: #c084fc; border: 1px solid rgba(147, 51, 234, 0.35); }
.tag-sec { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.35); }
.tag-css { background: rgba(56, 189, 248, 0.18); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.35); }
.tag-js  { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.tag-python { background: rgba(2, 132, 199, 0.18); color: #38bdf8; border: 1px solid rgba(2, 132, 199, 0.35); }
.tag-java   { background: rgba(234, 88, 12, 0.18); color: #fb923c; border: 1px solid rgba(234, 88, 12, 0.35); }
.tag-rust   { background: rgba(220, 38, 38, 0.18); color: #f87171; border: 1px solid rgba(220, 38, 38, 0.35); }
.apple-preset-card strong {
  font-size: 1.05rem;
  color: #f8fafc;
  letter-spacing: -0.01em;
}
.apple-preset-card p {
  margin: 0;
  font-size: 0.86rem;
  color: #94a3b8;
  line-height: 1.5;
}
.preset-arrow {
  margin-top: auto;
  padding-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #4ec9b0;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.apple-preset-card.is-hidden {
  display: none !important;
}

/* Apple View Toolbar */
.apple-view-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}
.view-modes-group {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.25rem;
  gap: 0.25rem;
}
.view-mode-btn {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.view-mode-btn.is-active {
  background: #4ec9b0;
  color: #0b1d1a;
  font-weight: 700;
}

/* Transformer Grid */
.transformer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  margin-top: 0.5rem;
}
@media (min-width: 1024px) {
  .transformer-grid.is-split {
    grid-template-columns: 1fr 1fr;
  }
}
.transformer-grid.show-only-legacy .code-panel.modern {
  display: none !important;
}
.transformer-grid.show-only-modern .code-panel.legacy {
  display: none !important;
}

/* Code Panels */
.code-panel {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease;
}
.code-panel.legacy {
  border-color: rgba(244, 63, 94, 0.3);
}
.code-panel.modern {
  border-color: rgba(16, 185, 129, 0.38);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 35px rgba(16, 185, 129, 0.08);
}
.code-panel-header {
  padding: 0.95rem 1.4rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 700;
}
.code-panel-header.legacy {
  color: #fda4af;
  border-left: 5px solid #f43f5e;
}
.code-panel-header.modern {
  color: #6ee7b7;
  border-left: 5px solid #10b981;
}
.code-input-area {
  width: 100%;
  min-height: 440px;
  background: transparent;
  color: #f1f5f9;
  font-family: Consolas, 'Fira Code', Monaco, monospace;
  font-size: 0.94rem;
  line-height: 1.65;
  padding: 1.25rem 1.4rem;
  border: none;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
}
.code-input-area:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.65);
}

@media (max-width: 720px) {
  .apple-preset-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    scroll-snap-type: x proximity;
  }
  .apple-preset-card {
    flex: 0 0 min(260px, 78vw);
    scroll-snap-align: start;
    padding: 1rem 1.1rem;
  }
}
.code-output-area {
  min-height: 440px;
  padding: 1.25rem 1.4rem;
  margin: 0;
  color: #e2e8f0;
  font-family: Consolas, 'Fira Code', Monaco, monospace;
  font-size: 0.94rem;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  background: #060911;
  box-sizing: border-box;
}

/* Bento Metrics */
.modern-metrics-bento {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.75rem;
}
.bento-metric-card {
  padding: 1.15rem 1.35rem;
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.22);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.bento-metric-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.bento-metric-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #6ee7b7;
  letter-spacing: -0.02em;
}

/* Deep Dive Feature Card */
.apple-deep-dive-card {
  margin-top: 2.5rem;
  padding: clamp(1.75rem, 3.5vw, 2.75rem);
  background: linear-gradient(135deg, rgba(20, 26, 40, 0.85), rgba(14, 18, 28, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.deep-dive-header {
  margin-bottom: 1.5rem;
  text-align: center;
}
.deep-dive-header h3 {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  color: #f8fafc;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.deep-dive-header p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.95rem;
  max-width: 650px;
  margin: 0 auto;
  line-height: 1.6;
}
.deep-dive-pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0 1.5rem;
}
.pillar-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.pillar-card span { font-size: 1.6rem; }
.pillar-card strong { font-size: 1rem; color: #f1f5f9; }
.pillar-card p { margin: 0; font-size: 0.86rem; color: #94a3b8; line-height: 1.5; }
.deep-dive-action {
  text-align: center;
  margin-top: 1.75rem;
}
