:root {
  --wada-oyster: #f5f5f0;
  --wada-iron: #2c4251;
  --wada-coral: #d16b54;
  --wada-blue: #2b4b6f;

  --bg-color: var(--wada-oyster);
  --text-color: var(--wada-iron);
  --accent-color: var(--wada-coral);
  --active-color: var(--wada-blue);
  --bg-alt: #ebebe5;
  --border-color: rgba(44, 66, 81, 0.2);

  --grad-1: rgba(209, 107, 84, 0.12);
  --grad-2: rgba(43, 75, 111, 0.08);
  --grad-3: rgba(212, 163, 92, 0.08);
}

[data-theme="dark"] {
  --bg-color: #1a1a19;
  --text-color: var(--wada-oyster);
  --accent-color: #e08b76;
  --active-color: #7eacc2;
  --bg-alt: #242422;
  --border-color: rgba(245, 245, 240, 0.2);

  --grad-1: rgba(209, 107, 84, 0.06);
  --grad-2: rgba(126, 172, 194, 0.05);
  --grad-3: rgba(43, 75, 111, 0.08);
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  background-color: var(--bg-color);
}

body {
  margin: 0;
  font-family: "Space Mono", "Courier New", Courier, monospace;
  background-color: transparent;
  color: var(--text-color);
  display: flex;
  min-height: 100vh;
  transition: color 0.3s ease;
  line-height: 1.6;
  font-size: 1rem;
  overflow-x: hidden;
}

/* --- THE SOLID GRADIENT MIXIN --- */
.solid-gradient {
  background-color: var(--bg-color);
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 15% 25%, var(--grad-1) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 80%, var(--grad-2) 0%, transparent 60%),
    radial-gradient(ellipse at 85% 20%, var(--grad-3) 0%, transparent 60%);
  background-attachment: fixed;
  transition: background-color 0.3s ease;
}

[data-theme="dark"] .solid-gradient {
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 15% 25%, var(--grad-1) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 80%, var(--grad-2) 0%, transparent 60%),
    radial-gradient(ellipse at 85% 20%, var(--grad-3) 0%, transparent 60%);
}

/* Base Viewport Background */
.grain-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120vh;
  z-index: -3;
  pointer-events: none;
}

/* The Dot Layer */
.grain-overlay::after {
  content: "";
  position: absolute;
  top: 60px;
  left: 300px;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 30px 30px;
  z-index: -2;
  transition: left 0.3s ease;
}

html[lang="pl"] .lang-en {
  display: none !important;
}
html[lang="en"] .lang-pl {
  display: none !important;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-weight: 700;
  margin-bottom: 1rem;
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition:
    color 0.2s,
    opacity 0.2s;
}
a:hover {
  opacity: 0.7;
}
p {
  max-width: 65ch;
  margin-bottom: 1.5rem;
}

#desktop-toggle {
  display: none !important;
}

/* --- UNIFIED HEADER (PC & Mobile) --- */
.sidebar {
  display: contents;
}

.sidebar-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border-color);
  z-index: 101;
}

.sidebar-header h1 {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 1.85rem;
  margin: 0;
  justify-self: center;
  white-space: nowrap;
}
.sidebar-header h1 a {
  color: var(--accent-color);
}

.menu-btn {
  justify-self: start;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
}
.header-controls {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.theme-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
}
.lang-btn {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-weight: 700;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.lang-btn:hover {
  opacity: 1;
}

/* --- UNIFIED SIDEBAR NAV (PC & Mobile) --- */
#nav-links {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: 300px;
  padding: 3rem 2rem;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}
body.sidebar-collapsed #nav-links {
  transform: translateX(-100%);
}

.nav-tree {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 1rem;
}
.nav-tree > li {
  margin-bottom: 1.2rem;
}
.nav-tree a {
  color: var(--text-color);
  text-decoration: none;
  display: block;
}
.nav-tree a:hover,
.nav-tree a.active,
.nav-tree a.expanded-parent {
  color: var(--active-color);
  opacity: 1;
}
.nav-tree a.active,
.nav-tree a.expanded-parent {
  font-weight: 700;
}

.tree-level-1 {
  list-style: none;
  padding-left: 1rem;
  margin-top: 0.8rem;
  border-left: 1px solid var(--border-color);
  display: none;
}
.tree-level-1 > li {
  margin-bottom: 0.8rem;
}
.tree-level-1 > li:last-child {
  margin-bottom: 0;
}
.tree-level-2 {
  list-style: none;
  padding-left: 1rem;
  margin-top: 0.8rem;
  border-left: 1px solid var(--border-color);
  display: none;
}
.tree-level-2 > li {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
}

.tree-level-1.open,
.tree-level-2.open {
  display: block;
}

/* --- MAIN CONTENT --- */
main {
  margin-top: 60px;
  margin-left: 300px;
  padding: 3rem 4rem;
  flex: 1;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
  transition: margin-left 0.3s ease;
}
body.sidebar-collapsed main {
  margin-left: 0;
}
body.sidebar-collapsed .grain-overlay::after {
  left: 0;
}

section,
article {
  flex: 1;
  margin-bottom: 4rem;
}

/* Profile Section & Images */
.profile-section {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 3rem;
  margin-top: 0;
}
.profile-photo {
  width: 160px;
  height: 160px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  cursor: zoom-in;
}

/* PC Grids */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}
.grid-item {
  display: block;
  color: var(--text-color);
}
.grid-image {
  width: 100%;
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border-color);
  transition: filter 0.3s;
}
.grid-item:hover .grid-image {
  filter: brightness(0.85);
}
.grid-title {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  text-align: left;
}
.grid-meta {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Facebook Event Grid */
.event-bg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2.5rem;
  margin-top: 3rem;
}
.event-bg-grid img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transition:
    transform 0.4s ease,
    box-shadow 0.4s ease;
  cursor: zoom-in;
}
.event-bg-grid img:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}
[data-theme="dark"] .event-bg-grid img {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .event-bg-grid img:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.event-bg-grid img:nth-child(3n + 1) {
  grid-column: 1 / -1;
}

.design-image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 3rem;
}
.design-image-grid img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border-color);
  cursor: zoom-in;
}
.design-image-grid img:first-child,
.design-image-grid img:last-child {
  grid-column: 1 / -1;
}

/* Tables & Lists */
.table-container {
  width: 100%;
  max-width: 100vw;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  text-align: left;
  margin-bottom: 1.5rem;
}
th,
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
th {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
.text-list {
  list-style: none;
  padding: 0;
}
.text-list li {
  margin-bottom: 0.5rem;
}

.cv-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}
.cv-year {
  opacity: 0.7;
}

/* Fixed Footer */
footer {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.sitemap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.sitemap a {
  color: var(--text-color);
}
.socials {
  display: flex;
  gap: 1rem;
}
.socials a {
  color: var(--text-color);
  display: inline-flex;
  width: 24px;
  height: 24px;
}
.socials a svg {
  width: 100%;
  height: 100%;
  display: block;
}
.socials a:hover {
  color: var(--accent-color);
}

/* --- LIGHTBOX MODAL --- */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 15, 14, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  cursor: zoom-out;
}
.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.lightbox.active img {
  transform: scale(1);
}

/* --- STRICT MOBILE LAYOUT --- */
@media (max-width: 768px) {
  .sidebar-header {
    padding: 0 1.5rem;
  }
  .grain-overlay::after {
    left: 0;
  }

  #nav-links {
    width: 280px;
    transform: translateX(-100%);
    padding: 3rem 1.5rem;
  }
  #nav-links.active {
    transform: translateX(0);
  }

  main {
    margin-left: 0;
    padding: 3rem 1.5rem 2rem 1.5rem;
  }
  body.sidebar-collapsed main {
    margin-left: 0;
    padding-left: 1.5rem;
  }

  .profile-section {
    display: block;
    margin-bottom: 2rem;
  }
  .profile-photo {
    float: left;
    margin: 0 1.2rem 0.5rem 0;
    width: 120px;
    height: 120px;
  }
  .profile-section::after {
    content: "";
    display: table;
    clear: both;
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .event-bg-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .event-bg-grid img:nth-child(3n + 1) {
    grid-column: auto;
  }

  .event-bg-grid img:hover {
    transform: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  }
  [data-theme="dark"] .event-bg-grid img:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
    width: 100%;
    min-width: auto;
  }
  thead {
    display: none;
  }
  tr {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 4px;
    overflow: hidden;
  }
  td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: normal;
    text-align: right;
  }
  td::before {
    content: attr(data-label-en);
    font-weight: 700;
    opacity: 0.7;
    font-size: 0.85rem;
    text-transform: uppercase;
    text-align: left;
    margin-right: 1rem;
  }
  html[lang="pl"] td::before {
    content: attr(data-label-pl);
  }

  footer {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 2rem;
  }
  .sitemap {
    justify-content: center;
  }
  .socials {
    justify-content: center;
    width: 100%;
  }
}
