@layer base, utilities, demo;
@import url("https://fonts.bunny.net/css?family=kodchasan:200,400,600") layer(demo);

/* ---------------------------
   DEMO LAYER
   (main gallery / stacking UI)
   --------------------------- */
@layer demo {
  section {
    --_offset-steps: 6rem;
    --_scale-steps: 25;
    --_opacity-steps: 15;
    --_ani-duration: 300ms;
    --_ani-delay: 200ms;

    --_offset-steps-two: calc(var(--_offset-steps) * -1);
    --_offset-steps-three: calc(var(--_offset-steps) * -2);

    --scale-steps-two: calc(1 - var(--_scale-steps) * 0.01);
    --scale-steps-three: calc(1 - var(--_scale-steps) * 0.02);

    --opacity-steps-two: calc(1 - var(--_opacity-steps) * 0.02);
    --opacity-steps-three: calc(1 - var(--_opacity-steps) * 0.04);

    display: grid;
    grid-template-areas: "stack";
    color: black;
    width: min(calc(100% - 2rem), 60rem);
  }

  @media (min-width: 600px) {
    section {
      --_offset-steps: 4em;
    }
  }

  article {
    --_bg-alpha: .5;
    --_border-radius: 10px;
    height: auto;
    position: relative;
    isolation: isolate;
    background: #272635;
    grid-area: stack;
    transition: 500ms ease-in-out;
    border-radius: var(--_border-radius);
    box-shadow: 0 10px 30px rgba(2,6,23,0.6), inset 0 1px 0 rgba(255,255,255,0.02);
    /* translate/scale/opacity controlled via custom properties */
    transform: translateY(var(--_offset, 0)) scale(var(--_scale, 1));
    order: var(--_order, 0);
    z-index: var(--_order, 0);
    opacity: var(--_opacity, 1);
    font-family: "Kanit", sans-serif;
    color: #f2f2f2;
  }

  /* pseudo elements */
  article::before,
  article::after {
    content: "";
    position: absolute;
    border-radius: inherit;
    z-index: -1;
  }

  article::before {
    z-index: -1;
    inset: calc(var(--_bg-dot-offset, 0) * -1);
    /* fallback if variables aren't defined */
    background-image: radial-gradient(var(--_bg-dot-color, rgba(255,255,255,0.06)) 1px, transparent 0px);
    background-repeat: repeat;
    background-size: 5px 5px;
    background-position: center;
    border-radius: calc(var(--_border-radius) + var(--_bg-dot-offset, 0));
  }

  article::after {
    background: #272635;
  }

  /* nth-of-type state placeholders (defaults) */
  article:nth-of-type(1) {
    --_bg-clr: rgba(163, 230, 53, var(--_bg-alpha, 1));
    --_order: var(--_1-order, 1);
    --_scale: var(--_1-scale, 1);
    --_opacity: var(--_1-opacity, 1);
    --_offset: var(--_1-offset, 0);
    --_pointer-event: var(--_1-pointer-event, auto);
    --_pointer-cursor: var(--_1-pointer-cursor, auto);
  }

  article:nth-of-type(2) {
    --_bg-clr: rgba(251, 191, 36, var(--_bg-alpha, 1));
    --_order: var(--_2-order, 1);
    --_scale: var(--_2-scale, 1);
    --_opacity: var(--_2-opacity, 1);
    --_offset: var(--_2-offset, 0);
    --_pointer-event: var(--_2-pointer-event, auto);
    --_pointer-cursor: var(--_2-pointer-cursor, auto);
  }

  article:nth-of-type(3) {
    --_bg-clr: rgba(249, 168, 212, var(--_bg-alpha, 1));
    --_order: var(--_3-order, 1);
    --_scale: var(--_3-scale, 1);
    --_opacity: var(--_3-opacity, 1);
    --_offset: var(--_3-offset, 0);
    --_pointer-event: var(--_3-pointer-event, auto);
    --_pointer-cursor: var(--_3-pointer-cursor, auto);
  }

  /* focus/checked interactions using :has() */
  section:has(input:nth-child(1):focus-visible) article:nth-of-type(1) label,
  section:has(input:nth-child(2):focus-visible) article:nth-of-type(2) label,
  section:has(input:nth-child(3):focus-visible) article:nth-of-type(3) label {
    transform: rotate(90deg);
  }

  section:has(input:nth-child(1):checked) {
    --_1-order: 3;
    --_1-scale: 1;
    --_1-opacity: 1;
    --_1-offset: 0;
    --_1-pointer-event: auto;
    --_1-pointer-cursor: pointer;

    --_2-order: 2;
    --_2-scale: var(--scale-steps-two);
    --_2-opacity: var(--opacity-steps-two);
    --_2-offset: var(--_offset-steps-two);

    --_3-order: 1;
    --_3-scale: var(--scale-steps-three);
    --_3-opacity: var(--opacity-steps-three);
    --_3-offset: var(--_offset-steps-three);
  }

  section:has(input:nth-child(2):checked) {
    --_2-order: 3;
    --_2-scale: 1;
    --_2-opacity: 1;
    --_2-offset: 0;
    --_2-pointer-event: auto;
    --_2-pointer-cursor: pointer;

    --_3-order: 2;
    --_3-scale: var(--scale-steps-two);
    --_3-opacity: var(--opacity-steps-two);
    --_3-offset: var(--_offset-steps-two);

    --_1-order: 1;
    --_1-scale: var(--scale-steps-three);
    --_1-opacity: var(--opacity-steps-three);
    --_1-offset: var(--_offset-steps-three);
  }

  section:has(input:nth-child(3):checked) {
    --_3-order: 3;
    --_3-scale: 1;
    --_3-opacity: 1;
    --_3-offset: 0;
    --_3-pointer-event: auto;
    --_3-pointer-cursor: pointer;

    --_1-order: 2;
    --_1-scale: var(--scale-steps-two);
    --_1-opacity: var(--opacity-steps-two);
    --_1-offset: var(--_offset-steps-two);

    --_2-order: 1;
    --_2-scale: var(--scale-steps-three);
    --_2-opacity: var(--opacity-steps-three);
    --_2-offset: var(--_offset-steps-three);
  }

  /* article inner layout */
  article > div {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    place-items: start;
    gap: 0rem;
    height: 90%;
  }

  @media (min-width: 900px) {
    article > div {
      grid-template-columns: 1fr 1fr;
    }
  }

  article img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    border-radius: 0 10px 0 0;
    transition: var(--_ani-duration) ease-in-out;
    opacity: var(--_opacity, 0);
    position: relative;
    margin: 0;
  }

  article .content {
    padding: 1rem;
    width: 100%;
    height: auto;
    overflow-y: auto;
    margin: 0 10px;
  }

  article p {
    transition: var(--_ani-duration) ease-in-out;
    transition-delay: 500ms;
    opacity: var(--_opacity, 0);
    margin: 0 0 1rem 0;
    font-size: 1rem;
  }

  article .content-text {
    padding: 10px;
    background-color: #353347;
    border-radius: 10px;
    margin-right: 10px;
    box-shadow: 0 5px 10px rgba(2,6,23,0.6), inset 0 1px 0 rgba(255,255,255,0.02);
  }

  /* footer / next-section (responsive) */
  article footer {
    width: 100%;
    display: grid;
  }

  article hr {
    margin: 0;
    border: none;
    border-top: 2px solid #f2f2f2;
  }

  article .next-section {
    display: grid;
    width: 100%;
    text-align: center;
    padding: 1rem 0;
  }

  @media (min-width: 900px) {
    article .next-section {
      grid-template-columns: 2fr 1fr 1fr;
      text-align: left;
      align-items: center;
    }
  }

  article .next-section label {
    cursor: pointer;
    transition: 300ms ease-in-out;
    font-size: 1.25rem;
	margin: 0;
  }

  article .next-section label:hover {
    color: #004EF5;
  }

  article .next-section .section-title {
    display: grid;
    width: 100%;
  }

  article .next-section .section-title h2 {
    padding-bottom: 12px;
    margin: 0.3rem 0 0 0;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 300;
  }

  article .next-section .navigation-up,
  article .next-section .navigation-down {
    display: grid;
    width: 100%;
    margin-top: 0.5rem;
  }

  article .next-section label {
    font-size: 24px;
	bottom: 10px;

  }

   @media (min-width: 900px) {
 article .next-section label {
	    position: relative;
    font-size: 24px;
    bottom: 15px;
    display: grid;
    justify-content: center;
 }

 article .next-section h2 {
	    position: relative;
    bottom: 0.7vh;
    left: 1vw;
 }
   }

  @media (max-width: 899px) {
    article .next-section h2 {
      margin: 0;
      line-height: 0.5;
      padding: 0;
    }

    article .next-section label {
      margin: 0;
      font-size: 18px;
    }
  }

  /* button-grid (mobile-first: stack) */
 article .button-grid { width: 100%; height: 100%; @media (width > 900px){ display: grid; grid-column: span 2; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); } } article .button-grid a { width: 100%; height: 100%; margin: 0; border: none; display: flex; justify-content: center; align-items: center; cursor: pointer; text-decoration: none; font-size: 70px; transition: 0.4s ease; @media (max-width: 899px){ height: 20%; } 

    /* make icons adapt on small screens */
    article .button-grid a i,
    article .button-grid a svg {
      display: block;
      width: 100%;
      text-align: center;
      line-height: 1;
      font-size: clamp(36px, 8vw, 70px);
      max-width: 100%;
    }
  }

  /* social button themes */
  .twitch { grid-column: span 2; background: #31007A; color: #f2f2f2;  border-radius: 10px 10px 0 0;  }
  .twitch:hover, .twitch:active { background: #f2f2f2; color: #31007A; }

  .twitter { background: black; color: #f2f2f2; }
  .twitter:hover, .twitter:active { background: #f2f2f2; color: black; }

  .youtube { background: #8F001D; color: #f2f2f2; }
  .youtube:hover, .youtube:active { background: #f2f2f2; color: #8F001D; }

  .bluesky { background: #0055CC; color: #f2f2f2; }
  .bluesky:hover { background: #f2f2f2; color: #0055CC; }

  .tiktok { background: #f2f2f2; color: black; }
  .tiktok:hover { background: black; color: #f2f2f2; }

  /* gallery section (repeat of earlier structure, kept for clarity) */
.gallery {
    width: 100%;
    grid-column: span 2;
    height: 100%;
    grid-row: span 2;
}

.gallery .picture-frame {
    display: flex;
    flex-direction: column;
    align-items: left;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.gallery .gallery-item {
    width: 100%;
    height: 450px;
    object-fit: contain;
    transition: opacity 1;
}

.gallery .info-container {
    background-color: #353347;
    border-radius: 5px;
    padding: 10px 30px;
    margin-top: 16px;
    box-shadow: 
        0 5px 10px rgba(2, 6, 23, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.gallery .gallery-item-title {
    font-size: 32px;
    font-weight: 300;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.gallery .gallery-author-link {
    text-decoration: none;
}

.gallery .gallery-item-desc {
    font-size: 42px;
    font-weight: 300;
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

.gallery .gallery-nav-container {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    margin-top: 16px;
}

.gallery .gallery-nav-buttons {
    cursor: pointer;
    background-color: #1E441E;
    padding: 10px;
    border-radius: 5px;
    transition: ease 0.5s;
}

.gallery .gallery-nav-buttons:hover,
.gallery-nav-buttons:active {
    background-color: #f2f2f2;
    color: #1E441E;
}

  @media (max-width: 899px) {
    .gallery .gallery-item-title{
      font-size: 28px;
    }

	.gallery .gallery-author-link{
      font-size: 14px;
    }

}
}

/* ---------------------------
   BASE LAYER
   --------------------------- */
@layer base {
  * { box-sizing: border-box; }

  :root {
    color-scheme: light dark;
    --bg-dark: rgb(24, 24, 27);
    --bg-light: rgb(229, 229, 229);

    --txt-light: rgb(10, 10, 10);
    --txt-dark: rgb(245, 245, 245);
  }

  body {
    background:
      radial-gradient(800px 400px at 10% 10%, rgba(124,58,237,0.08), transparent),
      radial-gradient(600px 300px at 90% 90%, rgba(6,182,212,0.06), transparent),
      var(--bg-dark);
    color: var(--txt-dark);
    min-height: 100svh;
    margin: 0;
    padding: 2rem;
    font-size: 1rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    line-height: 1.5;
    display: grid;
    place-items: center;
    gap: 2rem;
  }
}

/* ---------------------------
   UTILITIES LAYER
   --------------------------- */
@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
}
