/*
  Foglio di stile comune della sezione lessons.
  Gli stili dell’indice e delle pagine individuali restano isolati dagli stili dei tutorial.
*/

html {
  scroll-behavior: smooth;
}

/* Pagina principale delle lessons */
body.lesson-index-page {
  --color-page: #080a0d;
    --color-surface: #11151b;
    --color-surface-soft: #171d25;
    --color-text: #f5f7fa;
    --color-muted: #a7b0bd;
    --color-red: #ee343a;
    --color-border: rgba(255, 255, 255, 0.1);
    --font-main: Arial, Helvetica, sans-serif;
    --max-width: 1120px;
    --radius: 18px;
}

/* Reset e base della pagina lessons */

body.lesson-index-page,
body.lesson-index-page * {
  box-sizing: border-box;
}

body.lesson-index-page {
  display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: var(--color-text);
    font-family: var(--font-main);
    background: var(--color-page);
}

body.lesson-index-page main {
  flex: 1;
}

/* Layout pagina lessons */

body.lesson-index-page .lessons-layout {
  flex: 1;
    width: 50vw;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 40px;
    align-items: start;
}

body.lesson-index-page .page-content {
  width: min(calc(100% - 32px), var(--max-width));
    min-height: 62vh;
    margin: 0 auto;
    padding: 64px 0;
}

body.lesson-index-page .lessons-layout .page-content {
  width: 100%;
    margin: 0;
    padding: 64px 0;
}

body.lesson-index-page .page-section {
  margin-top: 64px;
}

body.lesson-index-page .page-kicker {
  margin: 0 0 12px;
    color: var(--color-red);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

body.lesson-index-page .page-title h1 {
  max-width: 900px;
    margin: 0;
    font-size: clamp(2.4rem, 6.5vw, 5.2rem);
    line-height: 0.98;
}

body.lesson-index-page .page-title h2 {
  max-width: 900px;
    margin: 8px 0 0;
    font-size: clamp(1.55rem, 4vw, 3.1rem);
    line-height: 1.05;
    font-style: italic;
}

body.lesson-index-page .page-description {
  max-width: 840px;
    margin: 24px 0 0;
    color: var(--color-muted);
    font-size: 1.08rem;
    line-height: 1.75;
}

body.lesson-index-page .page-description p {
  margin: 0;
}

body.lesson-index-page .page-description p + p {
  margin-top: 12px;
}

body.lesson-index-page .section-title {
  margin: 0 0 10px;
    color: #2aabf5;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    text-shadow: 0 0 20px #2aabf5b7;
}

body.lesson-index-page .section-description {
  max-width: 820px;
    margin: 0 0 24px;
    color: var(--color-muted);
    font-size: 1.02rem;
    line-height: 1.7;
}

body.lesson-index-page .card {
  padding: 24px;
    background: linear-gradient(180deg, var(--color-surface), var(--color-surface-soft));
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

body.lesson-index-page .card__title {
  margin: 0 0 10px;
    color: var(--color-red);
    font-size: 1.25rem;
}

body.lesson-index-page .card__text {
  margin: 0;
    color: var(--color-muted);
    line-height: 1.68;
}

/* Stili specifici della pagina lessons */

body.lesson-index-page .lesson-list {
  display: grid;
    gap: 16px;
}

body.lesson-index-page .lesson-list a {
  text-decoration: none;
}

body.lesson-index-page .lesson-card {
  display: grid;
    gap: 8px;
}

body.lesson-index-page .lesson-card__meta {
  color: var(--color-red);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

body.lesson-index-page .lesson-card--empty {
  border-style: dashed;
}

body.lesson-index-page #electronics,
body.lesson-index-page #arduino,
body.lesson-index-page #python {
  scroll-margin-top: 120px;
}

body.lesson-index-page #sidebar {
  width: 280px;
    margin-top: 64px;
    display: grid;
    gap: 18px;
    position: relative;
    overflow: hidden;
    padding: 18px;
    background: black;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
}

body.lesson-index-page .sidebar-extra {
  display: flex;
    flex-direction: column;
    padding: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

body.lesson-index-page .sidebar-extra a {
  margin-bottom: 5px;
    color: white;
}

body.lesson-index-page .sidebar-extra h3 {
  padding-bottom: 4px;
    margin-bottom: 5px;
    color: var(--color-red);
}

body.lesson-index-page .mobile-search {
  display: none;
    border-top: 1px solid #a7b0bd;
    border-bottom: 1px solid #a7b0bd;
}

body.lesson-index-page .search-panel::before {
  content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

body.lesson-index-page .search-panel__label {
  position: relative;
    display: block;
    margin: 0 0 12px;
    color: var(--color-red);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

body.lesson-index-page #searchBar,
body.lesson-index-page #searchBarMobile {
  position: relative;
    width: 100%;
    padding: 13px 14px;
    color: var(--color-text);
    font: inherit;
    background: rgba(8, 10, 13, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    outline: none;
    transition:
      border-color 0.2s ease,
      box-shadow 0.2s ease,
      background 0.2s ease;
}

body.lesson-index-page #searchBar::placeholder,
body.lesson-index-page #searchBarMobile::placeholder {
  color: rgba(167, 176, 189, 0.72);
}

body.lesson-index-page #searchBar:focus,
body.lesson-index-page #searchBarMobile:focus {
  background: rgba(8, 10, 13, 0.96);
    border-color: rgba(238, 52, 58, 0.75);
    box-shadow:
      0 0 0 4px rgba(238, 52, 58, 0.14),
      0 0 26px rgba(238, 52, 58, 0.22);
}

body.lesson-index-page .search-results {
  position: relative;
    display: none;
    gap: 12px;
    margin-top: 16px;
}

body.lesson-index-page .search-results.is-active {
  display: grid;
}

body.lesson-index-page .search-result-card {
  padding: 16px;
    cursor: pointer;
    background: linear-gradient(180deg, rgba(23, 29, 37, 0.95), rgba(17, 21, 27, 0.95));
    border-color: rgba(255, 255, 255, 0.14);
    transition:
      transform 0.2s ease,
      border-color 0.2s ease,
      box-shadow 0.2s ease;
}

body.lesson-index-page .search-result-card:hover,
body.lesson-index-page .search-result-card[data-focused="true"] {
  transform: translateY(-3px);
    border-color: rgba(245, 224, 42, 0.42);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32);
}

body.lesson-index-page .search-result-card .card__title {
  font-size: 1rem;
}

body.lesson-index-page .search-result-card .card__text {
  font-size: 0.92rem;
}

body.lesson-index-page .search-result-card .lesson-card__meta {
  font-size: 0.72rem;
}

body.lesson-index-page .search-empty {
  margin: 0;
    padding: 14px;
    color: var(--color-muted);
    font-size: 0.92rem;
    line-height: 1.5;
    background: rgba(8, 10, 13, 0.55);
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 14px;
}

body.lesson-index-page .lessons-layout article {
  user-select: none;
    cursor: pointer;
}

body.lesson-index-page .lessons-layout article:hover {
  border-color: rgba(241, 200, 200, 0.45);
}

@media (max-width: 1600px) {
  body.lesson-index-page .lessons-layout {
    width: 70vw;
  }
}

@media (max-width: 720px) {
  body.lesson-index-page .lessons-layout {
    display: block;
        width: min(calc(100% - 32px), var(--max-width));
  }

  body.lesson-index-page .page-content,
  body.lesson-index-page .lessons-layout .page-content {
    padding: 48px 0;
  }

  body.lesson-index-page .page-section {
    margin-top: 52px;
  }

  body.lesson-index-page #sidebar {
    display: none;
  }

  body.lesson-index-page .mobile-search {
    display: block;
        margin: 32px 0 0;
  }

  body.lesson-index-page .mobile-search .search-panel {
    padding: 16px;
  }

  body.lesson-index-page .mobile-search .search-results.is-active {
    display: flex;
        overflow-x: auto;
        gap: 12px;
        padding-bottom: 6px;
        scroll-snap-type: x proximity;
  }

  body.lesson-index-page .mobile-search .search-result-card {
    min-width: 240px;
        scroll-snap-align: start;
  }
}

/* Pagine individuali delle lessons */
body.lesson-detail-page {
  --color-page: #080a0d;
    --color-surface: #11151b;
    --color-surface-soft: #171d25;

    --color-text: #f5f7fa;
    --color-muted: #a7b0bd;

    --color-red: #ee343a;

    --color-border: rgba(255, 255, 255, 0.1);

    --font-main: Arial, Helvetica, sans-serif;

    --max-width: 1120px;
    --radius: 18px;
}

/* Reset e base della pagina lessons */

body.lesson-detail-page,
body.lesson-detail-page * {
  box-sizing: border-box;
}

body.lesson-detail-page {
  display: flex;
    align-items: center;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: var(--color-text);
    font-family: var(--font-main);
    background: var(--color-page);
}

body.lesson-detail-page main {
  flex: 1;
}

body.lesson-detail-page .page-content a {
  color: #6374d6;
}

body.lesson-detail-page .page-content {
  width: min(calc(100% - 32px), var(--max-width));
    min-height: 62vh;
    margin: 0 auto;
    padding: 64px 0;
}

body.lesson-detail-page .page-title h1 {
  margin: 0 0 2%;
    font-size: clamp(2.4rem, 6.5vw, 3.6rem);
    line-height: 0.95;
    color: var(--color-red);
}

body.lesson-detail-page .this_project-layout {
  display: flex;
      flex-direction: column;
      width: 100%;
}

body.lesson-detail-page .this_project-layout h2 {
  margin-bottom: 0;
      font-size: clamp(1.8rem, 3.1vw, 2.2rem);
      color:#097fe0;
}

body.lesson-detail-page .this_project-layout h3 {
  margin-bottom: 0;
      font-size: clamp(0.4rem, 1.9vw, 1rem);
      color:#09aee0;
}

body.lesson-detail-page .this_project-layout p {
  font-size: clamp(1rem, 1vw, 1.2rem);
      line-height: 1.6;
      color: #e5e7eb;
}

body.lesson-detail-page .this_project-layout ul {
  font-size: clamp(1rem, 1vw, 1.2rem);
      line-height: 1.6;
      color: #e5e7eb;
}

body.lesson-detail-page .this_project-image {
  display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-top: 2vh;
}

body.lesson-detail-page .this_project-image em {
  font-size: clamp(1rem, 1vw, 1.2rem);
      line-height: 1.6;
      color: #e5e7eb;
}

body.lesson-detail-page .this_project-image img {
  width: 80%;
      border-radius: 1vw;
      border: 2px solid var(--color-muted);
}

body.lesson-detail-page .this_project-double-image {
  margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
}

body.lesson-detail-page .this_project-double-image img {
  width: 40%;
      border-radius: 1vw;
      border: 2px solid var(--color-muted);
}

body.lesson-detail-page .tinkercad {
  display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 2vh;
}

body.lesson-detail-page .works p strong {
  font-style: italic;
}

/* ---- Area codice ---------------------- */

body.lesson-detail-page .code-area {
  display: flex; 
    margin: 0 auto 0;
    flex-direction: column;
    width: 90%;
    align-items: center; 
    justify-content: center;
}

body.lesson-detail-page .code-card {
  width: 100%;
    margin-top: 2vh;
    border: 3px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    background: #1f2b2e;
}

body.lesson-detail-page .code-header {
  min-height: 38px;
    padding: 0 14px;
    background: #050505;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

body.lesson-detail-page .code-header button img {
  width: 1vw;
}

body.lesson-detail-page .code-title {
  font-size: 1rem;
    color: #cfd8dc;
    font-family: Consolas, Monaco, "Courier New", monospace;
}

body.lesson-detail-page .code-card pre[class*="language-"] {
  margin: 0;
    border-radius: 2vh;
    background: #1f2b2e;
    padding-top: 22px;
    padding-bottom: 22px;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    line-height: 1.55 !important;

    max-height: 60vh;
    overflow: auto;

    white-space: pre !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

body.lesson-detail-page .code-card code[class*="language-"] {
  font-family: Consolas, Monaco, "Courier New", monospace;
    line-height: 1.55 !important;

    /* anche qui forziamo il no-wrap */
    white-space: pre !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

/* Numeri di riga */

body.lesson-detail-page .code-card .line-numbers .line-numbers-rows {
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}

body.lesson-detail-page .code-card .line-numbers-rows > span {
  display: block;
    line-height: 1.55 !important;
}

body.lesson-detail-page .code-card .line-numbers-rows > span:before {
  color: #7f8c91;
}

/* Colori del codice */

body.lesson-detail-page .token.comment {
  color: #7f9ca3;
}

body.lesson-detail-page .token.keyword {
  color: #00d4ff;
    font-weight: 700;
}

body.lesson-detail-page .token.function {
  color: #32c7ff;
}

body.lesson-detail-page .token.number {
  color: #f5c06a;
}

body.lesson-detail-page .token.string {
  color: #b8e986;
}

body.lesson-detail-page .token.operator,
body.lesson-detail-page .token.punctuation {
  color: #d7dee2;
}

body.lesson-detail-page .token.class-name {
  color: #c77dff;
}

/* Scrool bar */

body.lesson-detail-page .code-card pre[class*="language-"]::-webkit-scrollbar {
  width: 10px;
    height: 10px;
}

body.lesson-detail-page .code-card pre[class*="language-"]::-webkit-scrollbar-track {
  background: #172125;
}

body.lesson-detail-page .code-card pre[class*="language-"]::-webkit-scrollbar-thumb {
  background: #5f7378;
    border-radius: 10px;
    border: 2px solid #172125;
}

body.lesson-detail-page .code-card pre[class*="language-"]::-webkit-scrollbar-thumb:hover {
  background: #7f969c;
}

/* COPY BUTTONNNNN */

body.lesson-detail-page .copy-btn {
  border: 0;
    background: transparent;
    color: #cfd8dc;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
}

body.lesson-detail-page .copy-btn:hover {
  background: #1b2528;
}

body.lesson-detail-page .copy-btn.copied {
  color: #77e0a3;
}

/* ------------------------------------ */

@media (max-width: 1420px) {
  body.lesson-detail-page .page-content {
    width: 60vw;
  }
}

@media (max-width: 720px) {
  body.lesson-detail-page .page-content {
    width: 92vw;
  }

  body.lesson-detail-page .this_project-layout {
    width: 100%;
  }

  body.lesson-detail-page .this_project-layout h3 {
    margin-bottom: 0;
            font-size: clamp(0.8rem, 1.9vw, 1.3rem);
  }

  body.lesson-detail-page .this_project-image img {
    width: 98%;
            border-radius: 4vw;
  }

  body.lesson-detail-page .this_project-image iframe {
    width: 90%;
            border: 2px solid var(--color-muted);
  }

  body.lesson-detail-page .code-area {
    width: 100%;
  }

  body.lesson-detail-page .this_project-double-image {
    width: 48%;
          border-radius: 4vw;
  }
}

body.lesson-detail-page .steps h3 {
  padding: 0;
    margin: 30px 2px 10px;
    font-size: clamp(1.2rem, 1.9vw, 1.4rem);
}

body.lesson-detail-page .download_section h3 {
  padding: 0;
    margin: 10px 0 10px;
    font-size: 1.3rem;
    color: white;
}

/* Migliorie comuni ai pulsanti di copia */
/* Feedback accessibile e icona CSS per i pulsanti di copia */

body.lesson-detail-page .copy-btn {
  display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    color: #cfd8dc;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

body.lesson-detail-page .copy-btn:focus-visible {
  outline: 2px solid currentColor;
    outline-offset: 2px;
}

body.lesson-detail-page .copy-icon {
  position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    color: currentColor;
}

body.lesson-detail-page .copy-icon::before,
body.lesson-detail-page .copy-icon::after {
  content: "";
    position: absolute;
    width: 8px;
    height: 9px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
}

body.lesson-detail-page .copy-icon::before {
  left: 1px;
    top: 1px;
    opacity: 0.7;
}

body.lesson-detail-page .copy-icon::after {
  right: 1px;
    bottom: 1px;
    background: #050505;
}

body.lesson-detail-page .copy-btn[data-copy-feedback]::after {
  content: attr(data-copy-feedback);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

body.lesson-detail-page .copy-btn.copied {
  color: #77e0a3;
    background: rgba(119, 224, 163, 0.12);
}

body.lesson-detail-page .copy-btn.copy-error {
  color: #ff8a8f;
    background: rgba(238, 52, 58, 0.14);
}

/* Preserve the shared sticky sidebar on the lessons index page. */
body.lesson-index-page .lessons-layout #sidebar {
  position: sticky;
  top: 108px;
  align-self: start;
  max-height: calc(100vh - 124px);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 100;
  scrollbar-width: thin;
}

