/* Potassio.org - orange phosphor on black, faint stars in the background. */

:root {
  --bg:      #0d0805;
  --fg:      #e8cdb0;
  --fg-dim:  #8a6650;
  --accent:  #ff8a1e;
  --rule:    #2e1c10;
  --font:    ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* page changes cross-fade instead of flashing (where supported) */
@view-transition { navigation: auto; }

/* hidden must win over display rules set below (.photo-nav, img...) */
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

html {
  background: var(--bg);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 12px 18px, #ffffff 70%, transparent),
    radial-gradient(1.5px 1.5px at 134px 47px, #ffffff 55%, transparent),
    radial-gradient(1px 1px at 61px 132px, #ffffff 40%, transparent),
    radial-gradient(1px 1px at 178px 88px, var(--accent) 60%, transparent),
    radial-gradient(1px 1px at 22px 96px, #ffffff 50%, transparent),
    radial-gradient(1.5px 1.5px at 96px 205px, #ffffff 65%, transparent),
    radial-gradient(1px 1px at 210px 15px, #ffffff 35%, transparent),
    radial-gradient(1px 1px at 150px 170px, var(--accent) 45%, transparent),
    radial-gradient(1px 1px at 5px 150px, #ffffff 55%, transparent),
    radial-gradient(1.5px 1.5px at 70px 10px, #ffffff 45%, transparent);
  background-repeat: repeat;
  background-size:
    173px 173px, 229px 229px, 281px 281px, 197px 197px, 337px 337px,
    251px 251px, 397px 397px, 223px 223px, 307px 307px, 263px 263px;
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover { color: #fff; }
a:focus-visible { outline: 1px dashed var(--accent); outline-offset: 2px; }

.page {
  max-width: 74ch;
  margin: 0 auto;
  padding: 56px 20px 40px;
}
.page-narrow { max-width: 62ch; }

h1 {
  font-size: 1.6em;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 6px;
  font-weight: bold;
  text-wrap: balance;
}

h2 {
  font-size: 1.05em;
  color: var(--accent);
  margin: 0 0 10px;
  font-weight: bold;
}

.subtitle {
  color: var(--fg-dim);
  margin: 0;
}

/* il cane in text art sotto il titolo della home */
.dog {
  color: var(--fg-dim);   /* come il sottotitolo che ha sostituito */
  font-family: var(--font);
  line-height: 1.1;
  margin: 4px 0 0;
  font-size: 0.85em;
  overflow-x: auto;
  overflow-y: hidden;   /* senza, compare una barra di scorrimento verticale */
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 26px 0;
}

section p { margin: 10px 0; max-width: 62ch; }

.arrow-link { margin-top: 10px; }
.arrow-link::before { content: "\2192  "; color: var(--fg-dim); }

/* home: three small square photos */
.latest {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 480px;
  margin: 14px 0;
}
.latest a { display: block; }
.latest img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--rule);
}
.latest a:hover img { outline: 1px solid var(--accent); outline-offset: 2px; }

.back-link { display: inline-block; margin-bottom: 18px; color: var(--fg-dim); }
.back-link::before { content: "\2190  "; }
.back-link:hover { color: var(--accent); }

.muted { color: var(--fg-dim); }

footer {
  color: var(--fg-dim);
  font-size: 0.85em;
}
footer p { margin: 6px 0; }

/* ---------------------------------------------------------
   Feed (gallery.html): CSS columns keep every cover at its
   natural aspect ratio, no forced square crops. Albums get a
   badge in the top-right corner, single photos don't.
--------------------------------------------------------- */
.feed {
  columns: 3 220px;
  column-gap: 16px;
}

.tile {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 20px;
  color: inherit;
  text-decoration: none;
}

.tile-media {
  position: relative;
  overflow: hidden;
  background: var(--rule);
}

.tile-media img,
.photo-grid img,
.photo-single img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--rule);
}

/* album badge: two stacked squares, top-right */
.album::before,
.album::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 2px;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
}
.album::before { top: 10px; right: 10px; }
.album::after  { top: 14px; right: 14px; background: var(--bg); }

.tile-caption {
  margin: 8px 0 0;
  font-size: 0.85em;
  color: var(--fg-dim);
}
.tile:hover .tile-caption { color: var(--accent); }

/* ---------------------------------------------------------
   Post page (post.html): grid for albums, one large image
   for single photos.
--------------------------------------------------------- */
.description {
  max-width: 62ch;
  margin: 20px 0 0;
}
.description:empty { display: none; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px;
}
.photo-grid figure,
.photo-single figure { margin: 0; }
.photo-grid a { display: block; text-decoration: none; }

figcaption {
  margin-top: 8px;
  font-size: 0.85em;
  color: var(--fg-dim);
}
figcaption:empty { display: none; }

/* ---------------------------------------------------------
   Enlarged photo (photo.html): wider page, the whole photo
   always fits on screen.
--------------------------------------------------------- */
.page-wide { max-width: 1400px; }

.photo-view { margin: 0; }
.photo-view img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 78vh;   /* leaves room for back link and prev/next */
  max-height: 78dvh;
  width: auto;
  height: auto;
  background: var(--rule);
}
.photo-view figcaption { text-align: center; }

.photo-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 0;
}
.photo-nav a { color: var(--fg-dim); }
.photo-nav a:hover { color: var(--accent); }
.photo-nav .counter { color: var(--fg-dim); }

/* Videos take a whole row of the grid, so they aren't stamp-sized. */
.photo-grid .is-video { grid-column: 1 / -1; }
.photo-grid video,
.photo-single video {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
}

/* ---------------------------------------------------------
   Phones
--------------------------------------------------------- */
@media (max-width: 600px) {
  .page { padding: 28px 16px 32px; }

  /* bigger touch targets */
  .back-link,
  .photo-nav a { padding: 10px 0; }
  .back-link { margin-bottom: 8px; }

  /* enlarged photo edge to edge, taller */
  .photo-view { margin: 0 -16px; }
  .photo-view img { max-height: 82vh; max-height: 82dvh; }
  .photo-view figcaption { padding: 0 16px; }
  .photo-nav { align-items: center; }
}

/* phone turned sideways: the photo gets almost the whole height */
@media (max-height: 500px) and (orientation: landscape) {
  .page-wide { padding-top: 8px; padding-bottom: 12px; }
  .page-wide .back-link { margin-bottom: 4px; padding: 4px 0; }
  .photo-view img { max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); }
  .photo-nav { margin-top: 6px; }
}
