:root {
  --timonix-color: #ff6f00;
  --timonix-color-rgb: 255, 111, 0;

  --theme-bg: rgb(8 8 8);
  --theme-bg-section: rgb(14 14 14);
  --theme-bg-item: rgb(18 18 18);
  --theme-accent: rgb(198 33 37);
  --theme-accent-border: rgb(138 24 17);
  --theme-border: rgb(40 40 40);
  --theme-title-fc: rgb(140 140 140);
  --theme-text-accent: lightgray;

  --theme-search-bg: rgb(24 24 24); /* rgb(13 16 20) */
  --theme-search-bg-item: rgb(30 30 30); /* rgb(16 19 25) */
  --theme-search-border: rgb(34, 34, 34);
  --theme-search-form-bg: rgb(25 27 32);
  --theme-search-select-bg: rgb(18 20 25);
  --theme-bg-dot: rgb(79 79 79);


  --selectoption-bg-dark: #111214;
  --selectoption-bg-dropdown: #161719;
  --selectoption-bg-hover: #202225;
  --selectoption-text-main: #f5f5f5;
  --selectoption-text-muted: #62656c;
  --selectoption-accent-red: #ff3333;
}

#timonix {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  color: white;
  background-color: var(--theme-bg);

  #nav {
    border-bottom: 1px solid var(--theme-border);

    display: flex;
    width: 100%;
    height: 40px;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;

    & :is(section, nav, iframe) {
      height: 100%;
    }

    .logo {
      padding: 0;
    }

    #logo {
      padding: 5px;
      img {
        width: 30px;
        height: 30px;
      }
    }

    #timonix-pl {
      width: 200px;
      
      iframe {
        width: 200px;
      }
    }

  }
  
  main {
    margin-inline: 25px;

    :is(#favorited, #search, #recommended, #search-history, #my-materials) {
      margin-block: 7.5px;
      background-color: var(--theme-bg-section);
      border: 1px solid var(--theme-border);
      border-radius: 15px;
      padding: 5px;
      padding-bottom: 20px;
      padding-top: 0;
    }

    .section-title {
      display: flex;
      font-size: clamp(0.7rem, 1.2vw, 1.2rem);
      text-decoration: solid;

      svg {
        width: 20px;
        height: 20px;
        fill: var(--theme-accent);
        vertical-align: middle;
      }

      > div {
        width: 50%;
        
        .item-count {
          font-size: clamp(0.5rem, 0.7vw, 1rem);
          color: var(--theme-title-fc);
        }
      }
    }

    #search {
      position: relative;
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-content: center;
      justify-content: center;
      align-items: center;
      min-height: 80px;
      padding: 10px;
      border: 1px solid var(--theme-border);
      background-color: var(--theme-search-bg);  

      form {
        gap: 10px;
      }

      #search-twist {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-content: center;
        justify-content: center;
        align-items: center;
        width: 40dvw;
        border-radius: 10px;
        background-color: var(--theme-search-bg-item);


        input, textarea {
          min-height: 50px;
          background-color: transparent;
          border: none;
          color: white;
          outline: none;
          box-shadow: none;
          border-radius: 0;
          margin: 0;
          padding: 5px;
          font-size: clamp(0.6rem, 0.7vw, 2rem);
          resize: none;
          box-sizing: border-box;
          transition: all 0.1s ease-in-out;

          &::placeholder {
            color: white;
          }

          &:placeholder-shown {
            box-sizing: border-box;
            padding-top: 20px;
            line-height: 14px;
            transition: all 0.1s ease-in-out;
          }
        }

        select, selectgroup {
          max-width: 350px;
          height: 50px;
          margin: 0;
          margin-inline: 4px;
          border: transparent;
          border-radius: 10px;
          background: var(--theme-search-select-bg);
        }
        
        button {
          width: 50px;
          height: 50px;
          border: none;
          border-radius: 10px;
          margin: 0;
          padding: 10px;
          background-color: var(--theme-accent);

          svg {
            width: auto;
            height: 100%;
            fill: white;
            stroke: none;
          }
        }
      }
      #toggle-fullscreen {
        width: 50px;
        height: 50px;
        background-color: var(--theme-bg-item);
        border: 1px solid var(--theme-border);
        box-shadow: none;
        border-radius: 15px;
        padding: 17px;
        margin: 0;

        svg {
          width: auto;
          height: 100%;
          fill: white;
          stroke: none;
        }
      }

      &::before {
        content: "";
        position: absolute;
        top: -1px;
        right: 15%;
        width: 40%;
        height: 1px;
        background-color: var(--theme-accent);
        background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(198, 33, 37, 1) 35%, rgba(184, 31, 34, 1) 65%, rgba(0, 0, 0, 0) 100%);
        box-shadow: 0px 0px 20px 1px var(--theme-accent), 0px 0px 10px 1px var(--theme-accent);
        border-radius: 100%;
      }
    }
  }

  .carousel_slide {
    width: 130px;
    height: 130px;
    overflow: visible;

    .card {
      position: relative;
      width: 125px;
      height: 125px;
      padding: 10px;
      background: transparent;
      background-color: var(--theme-bg);
      border: 1px solid var(--theme-border);
      overflow: visible;

      img {
        width: 75px;
        height: 75px;
        object-fit: cover;
        object-position: center;
        border-radius: 5px;
      }

      svg {
        fill: white;
        image-rendering: optimizespeed;
        object-fit: fill;
        width: 100%;
        height: 100%;
        padding: 25%;
      }

      .card-title {
        display: -webkit-box;
        padding-top: 5px;
        font-size: 12px;
        font-weight: lighter;
        word-break: break-all;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        box-orient: vertical;
        line-height: 1.2;
        hyphens: auto;
        overflow: hidden;
      }

      .item-menu {
        position: absolute;
        top: 0;
        right: 0;
        width: 25px;
        height: 25px;
        z-index: 10;
        
        .item-menu-dot {
          display: flex;
          flex-direction: column;
          flex-wrap: nowrap;
          justify-content: space-around;
          width: 100%;
          height: 100%;
          padding: 2.5px;
          background-color: color(srgb 0 0 0 / 0.08);
          backdrop-filter: blur(10px) brightness(0.5) opacity(0.5);
          anchor-name: --item-menu-anchor;
          transition-delay: 1s;
          transition: opacity 0.3s ease, visibility 0.3s ease;
          opacity: 0;
          visibility: hidden;
          
          div {
            width: 100%;
            height: 20%;
            background: white;
            border-radius: var(--border-radius);
            box-shadow: 0px 0px 10px black;
          }
        }

        .item-menu-list {
          display: none;
          flex-direction: column;
          flex-wrap: nowrap;
          align-content: flex-start;
          justify-content: flex-start;
          align-items: baseline;
          position: fixed;
          /* right: -85px;
          top: 20px; */
          border-radius: 5px;
          z-index: 10;
          position-anchor: --item-menu-anchor;
          /* position-area: center; */
          position-try-fallbacks: flip-block;
          justify-self: center;
          background-color: color(srgb 0 0 0 / 0.48);
          backdrop-filter: blur(10px) brightness(0.5) opacity(0.5);

          > div {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-content: center;
            justify-content: flex-start;
            align-items: center;
            gap: 10px;
            width: 150px;
            border: 1px solid var(--theme-border);
            border-radius: 5px;
            margin: 4px;
            padding: 2px;

            img, svg {
              width: 20px;
              height: 20px;
              padding: 5px;
            }

            span {
              color: white;
              font-size: clamp(0.5rem, 0.8rem, 1rem);
              text-align: justify;
            }
          }
        }

        &:hover > .item-menu-list {
          display: flex;
        }
      }

      &:hover :is(.item-menu-dot, .item-menu-trot) {
          opacity: 1;
          visibility: visible;
          transition-delay: 1s;
      }
    } 

  }

  #favorited {
    .carousel_slide {
      height: 90px;

      .card {
        height: 90px;

        img {
          width: 40px;
          height: 40px;
        }
      }
    }
  }
  
  /* recommended */
  #recommended {
    .card {
      display: flex;
      width: 200px;
      text-align: left;

      img {
        width: 50px;
        height: 50px;
      }

      .sub-title {
        display: grid;
        width: 100%;
        font-size: clamp(0.5rem, 0.8rem, 1rem);
        padding: 0 5px;

        > span {
          display: -webkit-box;
          padding: 2px;
          font-size: 12px;
          font-weight: lighter;
          word-break: break-all;
          -webkit-line-clamp: 2;
          line-clamp: 2;
          -webkit-box-orient: vertical;
          box-orient: vertical;
          line-height: 1.2;
          hyphens: auto;
          overflow: hidden;

          &:first-child {
            -webkit-line-clamp: 1;
            line-clamp: 1;
          }

          &:not(:first-child) {
            color: var(--theme-text-accent);
            -webkit-line-clamp: 3;
            line-clamp: 3;
          }

          &:last-child {
            margin-top: 5px;
            -webkit-line-clamp: 2;
            line-clamp: 2;
          }
        }

        .card-title {
          text-transform: uppercase;
          -webkit-text-stroke-width: medium;
          text-stroke-width: medium;

        }
      }

    }
  }

  .item-menu-trot {
    display: grid;
    gap: 20%;
    width: 100%;
    height: 100%;
    padding: 2px;
    margin-left: 5px;
    transition-delay: 1s;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 0;
    visibility: hidden;

    > div {
      width: 20%;
      height: 100%;
      border-radius: 100%;
      background-color: var(--theme-bg-dot);
    }
  }

  #search-history {
    .carousel_slide {
      align-content: start;
    }

    .card {
      display: flex;
      justify-content: space-between;
      gap: 5px;
      width: 100%;
      height: 25px;
      padding: 2.5px;
      border-left: none;
      border-right: none;
      border-bottom: none;
      border-radius: 0;
      background-color: transparent;
      font-size: clamp(8px, 11px, 14px);

      img {
        width: 20px;
        height: 20px;
      }

      .other-page-logo {
        flex-basis: 20px;
      }

      .other-page-title {
        flex-basis: 45%;
        text-align: left;
      }

      .other-page-provider {
        flex-basis: 20%;
      }

      .other-page-view-at {
        flex-basis: 20%;
      }

      .other-page-menu {
        flex-basis: 20px;
        height: 100%;
      }

      .sub-title {
        display: grid;
        width: 100%;
        font-size: clamp(0.5rem, 0.8rem, 1rem);
        padding: 0 5px;

        > span {
          display: -webkit-box;
          padding: 2px;
          font-size: 12px;
          font-weight: lighter;
          word-break: break-all;
          -webkit-line-clamp: 2;
          line-clamp: 2;
          -webkit-box-orient: vertical;
          box-orient: vertical;
          line-height: 1.2;
          hyphens: auto;
          overflow: hidden;

          &:first-child {
            -webkit-line-clamp: 1;
            line-clamp: 1;
          }

          &:not(:first-child) {
            color: var(--theme-text-accent);
            -webkit-line-clamp: 3;
            line-clamp: 3;
          }

          &:last-child {
            margin-top: 5px;
            -webkit-line-clamp: 2;
            line-clamp: 2;
          }
        }

        .card-title {
          text-transform: uppercase;
          -webkit-text-stroke-width: medium;
          text-stroke-width: medium;

        }
      }

    }
  }

  #my-materials {
    .carousel_slide {
      width: 250px;
      height: 150px;
      margin-inline: 5px;

      .card {
        display: flex;
        justify-content: space-between;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        width: 100%;
        height: 25px;
        padding: 2.5px;
        text-align: justify;

        .material-title, .material-content, .material-footer {
          padding-inline: 5px;
        }

        .material-title {
          display: flex;

          .card-title {
            height: min-content;
            padding-left: 4px;
            padding-top: 2px;
          }

          svg {
            width: 15px;
            height: 15px;
            padding: 0;
            padding-top: 2px;
            vertical-align: super;
            fill: var(--theme-title-fc);
          }
        }

        .material-content {
          display: -webkit-box;
          padding-top: 5px;
          font-weight: lighter;
          word-break: break-all;
          -webkit-line-clamp: 5;
          line-clamp: 5;
          -webkit-box-orient: vertical;
          box-orient: vertical;
          line-height: 1.2;
          hyphens: auto;
          overflow: hidden;
          font-size: clamp(0.4rem, 0.7rem, 0.9rem);
          color: var(--theme-text-accent);
        }
        
        .material-content:has(img) {
          width: 100%;
          text-align: center;
        }
        
        .material-footer {
          color: var(--theme-title-fc);
          font-size: clamp(0.5rem, 0.65rem, 0.9rem);
          line-height: 1rem;
        }
  
        img {
          width: 75px;
          height: 75px;
          backdrop-filter: drop-shadow(13px 15px 20px white) contrast(0.6);
        }
      }
    }
  }

  footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
    width: 100%;
    height: 30px;
    padding-inline: 10px;
    font-size: clamp(0.4rem, 0.6rem, 1rem);
    background-color: var(--theme-bg-section);
    border-top: 2px solid var(--theme-accent-border);

    img {
      width: 25px;
      height: 25px;
    }
  }




  

  selectgroup {
    position: relative;
    width: auto;
    max-width: 320px;
    display: block;
    color: var(--selectoption-text-main);
    box-sizing: border-box;
  }

  /* Ukrywamy techniczny checkbox */
  .select-toggle {
    display: none;
  }

  /* Definiujemy wyświetlanie kontenera <selecting> */
  selecting {
    display: block;
    anchor-name: --enginesselecting;
  }

  /* PRZYCISK GŁÓWNY */
  .select-trigger {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    border-radius: 8px;
    background-color: var(--selectoption-bg-dark);
    cursor: pointer;
    user-select: none;
  }

  .select-trigger .text {
    flex-grow: 1;
    margin-left: 10px;
    font-size: 14px;
    text-wrap: nowrap;

    display: -webkit-box;
    word-break: break-all;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    box-orient: vertical;
    line-height: 1.2;
    hyphens: auto;
    overflow: hidden;
  }

  .select-trigger .arrow {
    font-size: 10px;
    color: var(--selectoption-text-muted);
    transition: transform 0.2s ease;
  }

  /* MASZYNIE KOŃCOWA: TWÓJ TAG <dropdown> */
  dropdown {
    position: fixed;
    /* top: calc(100% + 6px); */
    /* left: 0; */
    min-width: 270px;
    /* width: auto; */
    max-width: 320px;
    background-color: var(--selectoption-bg-dropdown);
    border-radius: 8px;
    border: 1px solid #222;
    box-shadow: 0px 10px 35px rgba(0, 0, 0, 0.6);
    padding: 6px 0;
    z-index: 999;
    box-sizing: border-box;
    /* position: fixed; */
    top: anchor(--enginesselecting bottom);
    left: anchor(--enginesselecting left);
    position-try-options: flip-block, flip-inline;
    position-area: bottom left;
    margin: 0;
    /* border: 1px solid #ccc; */
    display: none;
    color: white
    /* height: auto; */
    /* bottom: 10px; */
  }

  /* ==========================================================================
    NOWA MAGIA CSS: OBSŁUGA OTWIERANIA PRZEZ <selecting> 
    ========================================================================== */

  /* "Jeśli wewnątrz selectgroup znajduje się zaznaczony checkbox, to pokaż <dropdown>" */
  selectgroup:has(.select-toggle:checked) dropdown {
    display: block;
  }

  /* "Jeśli wewnątrz selectgroup znajduje się zaznaczony checkbox, to obróć strzałkę" */
  selectgroup:has(.select-toggle:checked) .select-trigger .arrow {
    transform: rotate(180deg);
  }

  /* ========================================================================== */

  /* TYTUŁY SEKCJI */
  .select-group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--selectoption-text-muted);
    padding: 14px 16px 6px 16px;
    letter-spacing: 0.6px;
  }

  /* OPCJE (Wiersze) */
  .select-option {
    display: block;
    cursor: pointer;
  }

  .select-option input[type="radio"] {
    display: none;
  }

  .option-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 16px;
    font-size: 14px;
    transition: background 0.15s ease;
  }

  .engine-name {
    display: flex;
    align-items: center;
    gap: 5px;
  }
    font-size: clamp(0.5rem, 0.8rem, 1.2rem);
  }

  .select-option:hover .option-content {
    background-color: var(--selectoption-bg-hover);
  }

  /* PTASZKI ZAZNACZENIA */
  .select-option .checkmark {
    color: var(--selectoption-accent-red);
    font-weight: bold;
    display: none;
  }

  .select-option input[type="radio"]:checked + .option-content .checkmark {
    display: block;
  }

  .param-text {
    color: var(--selectoption-accent-red);
    font-size: 13px;
    font-family: monospace;
  }

  /* STOPKA */
  .select-footer {
    border-top: 1px solid #222;
    margin-top: 8px;

    &[disabled] * {
      color: #555!important;
      cursor: not-allowed!important;
      box-shadow: none!important;
      border: none!important;
      pointer-events: none;
    }
  }

  .add-engine-btn {
    background: none!important;
    border: none;
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 0;
    width: 100%!important;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
  }

  .add-engine-btn:hover {
    color: var(--selectoption-text-main);
  }

  .icon {
    font-size: 16px;
    align-items: center;
    justify-content: center;

    svg {
      width: 16px;
      height: 16px;

      path {
        width: 100%;
        height: 100%;
      }

      &.fill {
        fill: var(--theme-accent);
      }
    }
  }

}
