/* assets/style.css — no-class experiment */
:root {
  --ink:hsl(0 17% 28% / 1);
  --bg:#f9f9f9;
  --behind: color-mix(in srgb, var(--bg), black 0%);
  --bounce: color-mix(in srgb, var(--bg), black 10%);
  --oblivion: color-mix(in srgb, var(--behind), black 80%);
  --link:#80007f;
  --col: 960px;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --mono: 'Courier New', Courier, monospace;
  --serif: Georgia, 'Times New Roman', Times, serif;

  /* Fluid scale ratio (1.25-1.333 common for 6 levels) */
  --scale-ratio: 1.25;

  /* Base font (clamp ensures accessibility) */
  --base-font: clamp(1.125rem, 2.5vw, 1.3125rem);

  /* Heading clamps: min, preferred (vw-based), max */
  --h1-size: clamp(3rem, 8vw, 6rem);
  --h2-size: clamp(1.625rem, 4vw, 3rem);
  --h3-size: clamp(1.375rem, 3.25vw, 2.25rem);
  --h4-size: clamp(1.25rem, 2.75vw, 1.875rem);
  --h5-size: clamp(1.125rem, 2.25vw, 1.5rem);
  --h6-size: clamp(1rem, 1.75vw, 1.25rem);
}

*{ box-sizing: border-box;
 overflow-wrap: break-word; }

html {
  background-color: var(--bounce);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--behind);
  font-family: var(--serif);
  font-weight: 300;
  font-size: var(--base-font);
  line-height: 1.8;
  background-color: var(--behind);
}

header {
  margin: 0 auto;
  text-align: center;
  padding: 0.5rem 0;
  backdrop-filter: blur(10px);
  background-color: color-mix(in srgb, var(--bg) 80%, transparent);
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 99;
  overflow: hidden;

  nav {
    max-width: var(--col);
    margin: 0.5rem auto;
    display: block;
    text-align: left;
    font-size: clamp(0.5rem, 3vw, 1rem);
    text-decoration: none;
    font-family: var(--sans);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 1rem;

    a {
      text-decoration: none;
      color: inherit;
      &:hover {
        text-decoration: dashed 1px;
      }
    }

    /* Right-side menu: ul replaces div.menu */
    ul {
      float: right;
      list-style: none;
      padding: 0;
      margin: 0;
      display: inline;

      li {
        display: inline;
      }

      a {
        margin-left: 1em;
      }

      @media screen and (max-width: 480px) {
        a {
          margin-left: 0.7em;
        }
      }
    }
  }
}

main {
  max-width: var(--col);
  margin: 0 auto;
  background: var(--bg);
  padding: 1rem;
  /* box-shadow: 0 2px 12px #0001; */
}

img { max-width: 100%; height: auto; display: block; }
/* picture è trasparente al layout: non interferisce con float, grid, flex */
picture { display: contents; }
pre, code { background: var(--bg); padding: .2em .4em; border-radius: 4px; }
footer { max-width: var(--col); color: #777; margin: 3rem auto 0; }

blockquote {
  font-size: calc(.95 * var(--base-font));
  font-style: italic;
  margin: 2rem 0;
  padding: 0.25rem 0.25rem 0.25rem .25rem;
  position: relative;
}
blockquote cite {
  display: block;
  text-align: right;
  font-size: 0.72em;
  font-style: italic;
  opacity: 0.55;
  margin-top: 1rem;
}

/* ── Card grid: section replaces .wrapper ────────────────── */
section {
  align-items: stretch;
  column-gap: 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 2em auto;
  max-width: var(--col);
  padding: 0;
  row-gap: 20px;

  @media (max-width: 720px) {
    grid-template-columns: 1fr;
  }

  @media (min-width: 721px) and (max-width: 1100px) {
    grid-template-columns: 1fr 1fr;
  }

  /* ── Card: article replaces a.card ──────────────────────── */
  article {
    color: inherit;
    box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px;
    transition: all 0.3s;
    border-radius: 1rem;
    margin: 0;
    padding: 0;
    overflow: hidden;

    a {
      text-decoration: none;
      color: black;
      display: block;
      /* prevent a:hover gradient from kicking in on card links */
      background: none !important;
      -webkit-background-clip: initial !important;
      background-clip: initial !important;
      color: inherit !important;
    }

    /* ── Card figure replaces figure.card-figure ─────────── */
    figure {
      overflow: hidden;
      height: 8rem;
      background-color: var(--oblivion);
      margin: 0;
      padding: 0;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        /* override main img rules */
        box-shadow: none;
        border-radius: 0;
        margin-block: 0;
      }
    }

    p {
      padding: 1rem;
      margin: 0;
    }

    &:hover {
      box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 4px;
      transform: scale(0.99);
    }
  }
}

/* ── Language switcher: nav a[lang] ─────────────────────── */
nav a[lang] {
  font-family: var(--sans);
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1.5px solid currentColor;
  padding: 0.15em 0.45em;
  border-radius: 3px;
  text-decoration: none !important;
  background: none !important;
  background-clip: unset !important;
  color: inherit !important;
  opacity: 0.65;
  transition: opacity 0.2s;
  margin-left: 0.6em;
  vertical-align: middle;
}
nav a[lang]:hover {
  opacity: 1;
}
nav span[aria-disabled="true"] {
  font-family: var(--sans);
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1.5px solid currentColor;
  padding: 0.15em 0.45em;
  border-radius: 3px;
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
  margin-left: 0.6em;
  vertical-align: middle;
}

/* ── Translation notice: aside ──────────────────────────── */
aside {
  background: color-mix(in srgb, var(--link) 12%, transparent);
  border-left: 3px solid var(--link);
  padding: 0.6rem 1rem;
  margin-bottom: 2rem;
  font-size: 0.88em;
  font-family: var(--sans);
  color: var(--ink);
}

/* ── Shadow on inline images in post content ─────────────── */
main img {
  box-shadow: 0 4px 20px hsl(0 0% 0% / 0.12);
  border-radius: 4px;
  margin-block: 1rem;
}
/* ── Shadow on inline images in post content ─────────────── */
main p img {
  float:left;
  margin-right: 1rem;
}

/* ── Image sizing system: figure[data-layout] ────────────── */
figure {
  margin: 1.5rem 0;
}

/* masthead: full-bleed hero, altezza fissa per lasciare il titolo visibile
   al primo scroll sia desktop che mobile */
figure[data-layout="masthead"] {
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  margin-top: -1rem; /* compensa il padding di main */
  margin-bottom: 2rem;
  height: 55vh;
  overflow: hidden;
}
figure[data-layout="masthead"] img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal, center center);
  border-radius: 0;
  box-shadow: none;
  margin-block: 0;
}

figure[data-layout="cover"] {
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  border-radius: 0;
}
figure[data-layout="cover"] img {
  width: 100%;
  border-radius: 0;
}
figure[data-layout="wide"] {
  width: calc(100% + 6rem);
  margin-left: -3rem;
  @media (max-width: 720px) { width: 100%; margin-left: 0; }
}
figure[data-layout="wide"] img {
  width: 100%;
}
figure[data-layout="half"] {
  width: 50%;
  float: left;
  margin: 0 0 1rem 0;
  padding-right: 0.75rem;
  box-sizing: border-box;
  @media (max-width: 480px) { width: 100%; float: none; padding-right: 0; }
}
figure[data-layout="half"] img {
  width: 100%;
}
img[data-layout="inline"] {
  float: left;
  width: auto;
  margin: 0 1.25rem 0.5rem 0;
  display: inline;
}
img[data-layout="inline-right"] {
  float: right;
  width: auto;
  margin: 0 0 0.5rem 1.25rem;
  display: inline;
}

/* ── Typography ──────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 {
  line-height: 1.2;
  font-family: var(--sans);
  margin: 0;
  clear: both;
}

a {
  color: var(--link);
}

h1,h2,h3,h4,h5,h6, strong, a:hover {
  background-image: linear-gradient(hsl(300, 100%, 25%), hsl(300, 100%, 10%));
  color: transparent;
  background-clip: text;
  border-bottom: none;
}

h1 { font-size: var(--h1-size); line-height: 1.2; font-weight: 800; }
h2 { font-size: var(--h2-size); line-height: 1.3; font-weight: 700; padding-top: 4rem; }
h3 { font-size: var(--h3-size); line-height: 1.4; font-weight: 600; }
h4 { font-size: var(--h4-size); line-height: 1.4; font-weight: 600; }
h5 { font-size: var(--h5-size); line-height: 1.5; font-weight: 500; }
h6 { font-size: var(--h6-size); line-height: 1.5; font-weight: 500; }

strong { font-weight: 600; }

/* ── Occhiello / kicker label: ::testo:: → <b> ──────────── */
b {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #303;
  margin: 0;
}
p:has(b) {
  margin: 0;
}

footer {
  border-top: var(--ink) 1px solid;
  font-size: var(--base-font-small);
}

/* ── Gallery ─────────────────────────────────────────────── */

/*
  Sintassi markdown per le gallerie (post con layout photo_post.njk):

  Due o più immagini consecutive senza riga vuota → gruppo galleria.

  Alt text controls:
    ![caption](url)           → peso 1 (default)
    ![2|caption](url)         → peso numerico (fr unit)
    ![pair|caption](url)      → layout predefinito (sul primo del gruppo)

  Named layouts: full · pair · feature · triptych · mosaic
*/

.gallery {
  display: grid;
  grid-template-columns: var(--gallery-cols, 1fr 1fr);
  gap: 0.25rem;
  margin: 2rem 0;
}

/* picture è display:contents globalmente, ma nel grid deve essere un item */
.gallery picture {
  display: block;
  overflow: hidden;
}

.gallery img {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: none;
  border-radius: 0;
  margin-block: 0;
}

/* ── Named layouts ───────────────────────────────────────── */
.gallery[data-layout="full"]     { grid-template-columns: 1fr; }
.gallery[data-layout="pair"]     { grid-template-columns: 1fr 1fr; }
.gallery[data-layout="feature"]  { grid-template-columns: 3fr 2fr; }
.gallery[data-layout="triptych"] { grid-template-columns: 1fr 1fr 1fr; }

.gallery[data-layout="mosaic"] {
  grid-template-columns: 2fr 1fr;
  align-items: stretch;
}
.gallery[data-layout="mosaic"] picture:first-child {
  grid-row: 1 / span 2;
}
.gallery[data-layout="mosaic"] picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Mobile: sempre colonna singola ──────────────────────── */
@media (max-width: 640px) {
  .gallery,
  .gallery[data-layout] {
    grid-template-columns: 1fr !important;
    --gallery-cols: 1fr !important;
  }
  .gallery[data-layout="mosaic"] picture:first-child {
    grid-row: auto;
  }
  .gallery[data-layout="mosaic"] picture img {
    height: auto;
  }
}

/* ── Photo post: testo in colonna, gallerie nella colonna ── */
.photo-post main {
  padding-left: 0;
  padding-right: 0;
}

.photo-post main > *:not(.gallery) {
  padding-left: 1rem;
  padding-right: 1rem;
}

.photo-post .gallery {
  gap: 0.35rem;
  margin-top: 3rem;
  margin-bottom: 3rem;
}

/* ── Mosaic alternato: dispari = grande a sinistra,
                        pari   = grande a destra ──────────── */
.gallery[data-layout="mosaic"]:nth-child(even of .gallery[data-layout="mosaic"]) {
  grid-template-columns: 1fr 2fr;
}
.gallery[data-layout="mosaic"]:nth-child(even of .gallery[data-layout="mosaic"]) picture:first-child {
  grid-column: 2;
  grid-row: 1 / span 2;
}

@media (max-width: 640px) {
  .gallery[data-layout="mosaic"]:nth-child(even of .gallery[data-layout="mosaic"]) picture:first-child {
    grid-column: auto;
    grid-row: auto;
  }
}

/* ── Dark mode ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --ink:    hsl(30 8% 83%);
    --bg:     hsl(220 12% 13%);
    --behind: hsl(220 12% 13%);
    --bounce: hsl(220 12% 8%);
    --link:   hsl(270, 80%, 75%);
  }

  h1,h2,h3,h4,h5,h6, strong, a:hover {
    background-image: linear-gradient(hsl(300, 70%, 80%), hsl(300, 70%, 62%));
  }

  b {
    color: hsl(300, 45%, 70%);
  }

  blockquote::before {
    background-image: repeating-linear-gradient(
      to bottom,
      hsl(300, 70%, 72%) 0px,
      hsl(300, 70%, 72%) 6px,
      transparent 6px,
      transparent 14px
    );
  }

  main img {
    box-shadow: 0 4px 20px hsl(0 0% 0% / 0.4);
  }

  section article {
    box-shadow: rgba(0, 0, 0, 0.5) 0px 2px 8px;
  }
}
