/* style.css: the whole look of bissenali.com. System fonts, one column, one accent colour.
   Light and dark follow the reader's system setting. No webfonts, no framework. */

:root {
  color-scheme: light dark;
  --bg: #ffffff; --ink: #1b1b1b; --muted: #636363; --rule: #e6e6e6; --accent: #1f4fbf;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --col: 46rem; --measure: 41rem;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131416; --ink: #e3e3e1; --muted: #9b9b98; --rule: #2a2c30; --accent: #8fb4ff; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16.5px/1.6 var(--font-body); }
img, audio, svg { max-width: 100%; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
time { font-variant-numeric: tabular-nums; }
.page { max-width: var(--col); margin: 0 auto; padding: 3.25rem 1.25rem 4rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2.5px;
    text-decoration-color: color-mix(in srgb, currentColor 38%, transparent); }
a:hover { text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

h1 { font-size: 1.95rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.018em; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 2.9rem 0 .9rem; font-weight: 700; letter-spacing: -.005em; }

/* ---- header and nav ---- */
.masthead, .topbar { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .3rem 1.5rem; }
.masthead { margin-bottom: 1.6rem; }
.topbar { margin-bottom: 2.75rem; padding-bottom: .9rem; border-bottom: 1px solid var(--rule); }
.topbar .home { font-weight: 600; text-decoration: none; color: var(--ink); }
nav a { margin-left: 1.2rem; text-decoration: none; color: var(--muted); }
nav a:first-child { margin-left: 0; }
nav a:hover, nav a[aria-current] { color: var(--ink); }

/* ---- home: bio on the left, the picture and the die on the right ---- */
.intro { display: grid; grid-template-columns: minmax(0, 1fr) 13rem; gap: 2.25rem; align-items: start; }
.bio p { margin: 0 0 .9em; }
.bio p:last-child { margin-bottom: 0; }
.contact { font-size: .9rem; color: var(--muted); margin: .9rem 0 0; line-height: 1.55; }

.rollcard { --pin: var(--accent); }
.frame { position: relative; aspect-ratio: 1; border-radius: 4px; overflow: hidden;
         background: color-mix(in srgb, var(--ink) 6%, var(--bg)); }
.frame .me, .frame .shot, .frame .zoom { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame .me, .frame .shot { object-fit: cover; }
.frame .shot, .frame .zoom { display: none; }          /* the portrait shows until the die is rolled */
.rolled .frame .me { display: none; }
.rolled.has-photo .frame .shot, .rolled:not(.has-photo) .frame .zoom { display: block; }
.many .frame .shot { cursor: pointer; }                 /* several pictures: click for the next */
.frame .shot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rollcard.nojs .rollbtn, .rollcard.nojs .where { display: none; }   /* without JavaScript there is nothing to roll */
.shotcap { display: none; font-size: .78rem; line-height: 1.35; color: var(--muted); margin: .4rem 0 0; min-height: 1.35em; }
.rolled.has-photo .shotcap { display: block; }
.where { font-size: .9rem; line-height: 1.45; margin: .65rem 0 .7rem; color: var(--muted); }
.rolled .where { color: var(--ink); min-height: 5.8em; }

/* The die is a real button, so it reads as something to press. */
.rollbtn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .45rem .7rem;
           font: inherit; font-weight: 600; color: var(--ink); background: var(--bg); cursor: pointer; text-align: left;
           border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent); border-radius: 8px;
           box-shadow: 0 2px 0 color-mix(in srgb, var(--ink) 50%, transparent); }
.rollbtn:hover { border-color: var(--ink); box-shadow: 0 2px 0 var(--ink); background: color-mix(in srgb, var(--ink) 5%, var(--bg)); }
.rollbtn:active { transform: translateY(2px); box-shadow: none; }
.die { display: block; width: 1.7rem; height: 1.7rem; flex: none; }
.die svg { display: block; width: 100%; height: 100%; }
.die rect { fill: none; stroke: currentColor; stroke-width: 2.4; }
.die .p { fill: currentColor; display: none; }
.n1 .c, .n3 .c, .n5 .c, .n2 .tl, .n2 .br, .n3 .tl, .n3 .br, .n4 .tl, .n4 .tr, .n4 .bl, .n4 .br,
.n5 .tl, .n5 .tr, .n5 .bl, .n5 .br, .n6 .tl, .n6 .tr, .n6 .ml, .n6 .mr, .n6 .bl, .n6 .br { display: inline; }
.die.tumble { animation: tumble .28s ease-out; }
.rollcard:not(.rolled) .die { animation: nudge 1.1s ease-in-out 1.4s 1 both; }   /* one wiggle after the page loads */
@keyframes tumble { from { transform: rotate(-90deg) scale(.86); } to { transform: none; } }
@keyframes nudge { 0%, 100% { transform: none; } 25% { transform: rotate(-16deg); } 55% { transform: rotate(13deg); } 80% { transform: rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { .die.tumble, .rollcard:not(.rolled) .die { animation: none; } }
.back { display: none; margin: .55rem 0 0; padding: 0; font: inherit; font-size: .82rem; color: var(--muted);
        background: none; border: 0; text-decoration: underline; text-underline-offset: 2.5px; cursor: pointer; }
.rolled .back { display: block; }

/* ---- maps: dotted land, pins, zoom ---- */
.sprite { position: absolute; }
.map { display: block; width: 100%; height: auto; overflow: hidden; }
.land use { fill: none; stroke: var(--ink); stroke-linecap: round; opacity: .24; }
.land .coarse { stroke-width: 3.7; stroke-dasharray: 0 6.4; }     /* each run of land becomes a row of dots */
.land .fine { stroke-width: 1.5; stroke-dasharray: 0 2.4; display: none; }
.map.fine .land .coarse { display: none; }
.map.fine .land .fine { display: inline; }
.zoom .land use { opacity: .3; }

.pin { cursor: pointer; }
.zoomable .pinbody { transform: scale(calc(1 / var(--k, 1))); }   /* pins keep their size, so they separate as you zoom */
.pin .needle { stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; opacity: .8; }
.pin .pinhead { fill: var(--pin); stroke: rgba(0, 0, 0, .3); stroke-width: .6; }
.pin .shine { fill: #fff; opacity: .55; }
.pin .shadow { fill: #000; opacity: .22; }
.pin .ring { fill: none; stroke: var(--pin); stroke-width: 2.5; opacity: 0; }
.pin.here .ring { opacity: .9; }
.pin.dot .pinhead { stroke: none; }
.pin.dot .ring { stroke-width: 7; }
.pin:hover .pinhead, .pin:focus-visible .pinhead { stroke: var(--ink); stroke-width: 1.5; }
.pin:focus-visible { outline: none; }
.pin:focus-visible .ring { opacity: .9; }               /* the ring is what shows keyboard focus, at any map size */
.map .pins:has(.here) .pin:not(.here) { opacity: .5; }

.mapbox { position: relative; }
.mapzoom { position: absolute; top: .5rem; right: 0; display: flex; gap: .25rem; }
.mapzoom button { width: 1.75rem; height: 1.75rem; padding: 0; font: 600 1rem/1 var(--font-body); color: var(--ink);
                  background: var(--bg); border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); border-radius: 6px; cursor: pointer; }
.mapzoom button:hover:not(:disabled) { border-color: var(--ink); }
.mapzoom button:disabled { opacity: .35; cursor: default; }
.map.zoomed { cursor: grab; touch-action: none; }
.map.dragging { cursor: grabbing; }
.mapbox.small { margin-top: .95rem; }
.mapbox.small .mapzoom { position: static; justify-content: flex-end; margin-top: .3rem; }
.mapbox.small .mapzoom button { width: 1.35rem; height: 1.35rem; font-size: .85rem; border-radius: 5px; }

/* ---- lists on the home page ---- */
.papers { list-style: none; padding: 0; margin: 0; }
.papers li { padding: .85rem 0; border-top: 1px solid var(--rule); }
.papers li:last-child { border-bottom: 1px solid var(--rule); }
.papers p { margin: 0; }
.p-title a { font-weight: 600; color: var(--ink); }
.p-sum { margin: .2rem 0 !important; }
.p-meta { color: var(--muted); font-size: .9rem; }
.p-meta strong { color: var(--ink); font-weight: 600; }
.legend { color: var(--muted); font-size: .93rem; margin: .7rem 0 0; }

.rows { list-style: none; padding: 0; margin: 0; }
.rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.25rem; align-items: baseline;
           padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.rows li:first-child { border-top: 1px solid var(--rule); }
.rows .when { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.rows .desc { color: var(--muted); font-size: .95rem; }
.more { margin: .9rem 0 0; }
.foot { margin-top: 3.5rem; color: var(--muted); font-size: .86rem; }
.foot p { margin: .3rem 0 0; }

/* ---- inner pages: heading block, writing index ---- */
.sub h1 { font-size: 1.75rem; }
.page-head { margin-bottom: 2rem; }
.page-head h1 { margin: 0 0 .5rem; }
.lede { color: var(--muted); margin: 0 0 .6rem; max-width: 36rem; }
.langs { font-size: .9em; margin: 0; }
.group { margin-top: 2rem; }
.group h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.postlist { list-style: none; margin: 0; padding: 0; }
.postlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0 1rem; align-items: baseline;
               padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.postlist a { color: var(--ink); }
.postlist .kind { color: var(--muted); font-size: .8em; }
.postlist time { color: var(--muted); font-size: .88em; white-space: nowrap; min-width: 3.4em; text-align: right; }

/* ---- a note ---- */
.prose { max-width: var(--measure); }
.post-head { margin-bottom: 2rem; }
.post-head h1 { margin: 0 0 .5rem; }
.post-head .meta { color: var(--muted); font-size: .9em; margin: 0; }
.prose h2 { font-size: 1.3em; line-height: 1.3; margin: 2em 0 .6em; }
.prose h3 { font-size: 1.12em; line-height: 1.3; margin: 1.8em 0 .5em; }
.prose h4 { font-size: 1em; margin: 1.6em 0 .4em; }
.prose p { margin: 0 0 1.05em; }
.prose ul, .prose ol { padding-left: 1.35em; margin: 0 0 1.05em; }
.prose li { margin-bottom: .35em; }
.prose img { display: block; height: auto; margin: 1.6em auto; border-radius: 3px; }
.prose figure.media { margin: 1.6em 0; }
.prose figure.media img { margin: 0 auto; }
.prose audio { display: block; width: 100%; max-width: 26rem; margin: .4em 0 1.2em; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.2em 0; }
.prose blockquote { margin: 1.4em 0; padding: .1em 0 .1em 1.15em; border-left: 2px solid var(--rule); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose .callout { border-left-color: var(--accent); }
.prose .callout-title { font-family: var(--font-mono); font-size: .74em; letter-spacing: .06em; text-transform: uppercase;
                        color: var(--muted); margin: 0 0 .5em; }
.prose details { margin: 0 0 1.05em; }
.prose summary { cursor: pointer; color: var(--muted); }
.prose code { font-family: var(--font-mono); font-size: .88em; }

/* ---- places: the map stays in view while the notes scroll under it ---- */
.worldmap { position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--rule);
            margin: 0 -1rem; padding: .5rem 1rem .75rem; }       /* a little wider than the column, so tilted notes pass fully under it */
.worldmap .mapzoom { right: 1rem; }

/* Each place is a note pinned under the map. Clicking one selects its pin (map.js). */
.places { list-style: none; margin: 1.7rem 0 0; padding: 0; display: grid; align-items: start;
          grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 1.6rem 1.3rem; }
.place { position: relative; min-height: 10.5rem; padding: 1.6rem .95rem 1rem; border-radius: 2px; cursor: pointer;
         background: color-mix(in srgb, var(--pin) 15%, var(--bg));
         scroll-margin-top: calc(min(100vw - 2.5rem, var(--col)) * .435 + 3.2rem); }
.place::before { content: ""; position: absolute; top: .5rem; left: 50%; width: .72rem; height: .72rem; margin-left: -.36rem;
                 border-radius: 50%; background: var(--pin);                       /* the tack */
                 box-shadow: inset -1.5px -1.5px 0 rgba(0, 0, 0, .2), 0 1.5px 2px rgba(0, 0, 0, .35); }
.place h2 { font: inherit; font-weight: 600; line-height: 1.3; margin: 0; }
.place h2 a { color: inherit; text-decoration: none; }
.place .meta { color: var(--muted); font-size: .85rem; margin: .15rem 0 .45rem; }
.place p { margin: 0; font-size: .92rem; line-height: 1.45; }
.place .mini { display: none; }

/* The picture on a note. With several, it looks like a small pile and opens the viewer. */
.snap { position: relative; display: block; aspect-ratio: 1; margin: 0 0 .7rem; isolation: isolate; }
.snap img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 1px; }
.snap.multi::before, .snap.multi::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 1px;
                                          background: color-mix(in srgb, var(--ink) 12%, var(--bg)); border: 1px solid var(--rule); }
.snap.multi::before { transform: rotate(3.5deg); }
.snap.multi::after { transform: rotate(-2.5deg); }
.snap .count { position: absolute; right: .4rem; bottom: .4rem; padding: .22rem .45rem; border-radius: 999px;
               font: 600 .7rem/1 var(--font-mono); color: #fff; background: rgba(0, 0, 0, .62); }
.place:target { outline: 2px solid var(--pin); outline-offset: 3px; }

/* Notes sit slightly askew with a soft shadow, and straighten when touched or selected. */
.place { transform: rotate(var(--tilt, -1.3deg)); transition: transform .15s ease;
         box-shadow: 0 1px 1px rgba(0, 0, 0, .1), 0 9px 14px -10px rgba(0, 0, 0, .4); }
.place:nth-child(4n + 2) { --tilt: 1.5deg; }
.place:nth-child(4n + 3) { --tilt: -.5deg; }
.place:nth-child(4n) { --tilt: 2deg; }
.place:hover, .place:target { transform: none; }
@media (prefers-reduced-motion: reduce) { .place { transition: none; } }

/* polaroid (the one in use): a white card with a picture on top, the photo or a small map of the spot.
   Without this class the notes are plain tinted squares in each pin's colour ("tilted"). */
.notes-polaroid .place { min-height: 0; padding: .65rem .65rem .95rem; background: color-mix(in srgb, var(--ink) 3%, var(--bg));
                         border: 1px solid var(--rule); }
.notes-polaroid .place::before { top: -.36rem; }
.notes-polaroid .place .mini { display: block; width: 100%; height: auto; aspect-ratio: 1; margin: 0 0 .7rem;
                               background: color-mix(in srgb, var(--pin) 10%, var(--bg)); }
.notes-polaroid .place .mini .land use { opacity: .3; }
.notes-polaroid .place:nth-child(n) { --tilt: 0deg; }
.notes-polaroid .place:nth-child(3n + 1) { --tilt: -.8deg; }
.notes-polaroid .place:nth-child(3n) { --tilt: .9deg; }

/* ---- the photo viewer on the places page (photos.js) ---- */
.viewer:not([open]) { display: none; }                  /* also in browsers that do not know <dialog> */
.viewer { border: 0; padding: 0; background: transparent; color: #f2f2f2; max-width: 96vw; max-height: 96vh; overflow: visible; }
.viewer::backdrop { background: rgba(0, 0, 0, .88); }
.viewer figure { margin: 0; }
.viewer img { display: block; width: auto; height: auto; max-width: min(92vw, 1100px); max-height: 82vh; margin: 0 auto; border-radius: 2px; }
.viewer figcaption { text-align: center; font-size: .9rem; padding: .7rem 0 0; }
.viewer button { position: fixed; padding: .4rem .9rem; font: 300 2.6rem/1 var(--font-body); color: #f2f2f2; background: none; border: 0; cursor: pointer; }
.viewer button:hover { color: #fff; }
.v-prev { left: .4rem; top: 50%; transform: translateY(-50%); }
.v-next { right: .4rem; top: 50%; transform: translateY(-50%); }
.v-close { right: .5rem; top: .3rem; font-size: 2.1rem !important; }
.viewer.single .v-prev, .viewer.single .v-next { display: none; }

/* ---- narrow screens ---- */
@media (max-width: 640px) {
  .intro { grid-template-columns: 1fr; gap: 1.25rem; }
  .rollcard { order: -1; display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); column-gap: 1rem; align-items: start; }
  .rollcard .frame { grid-row: 1 / span 3; }
  .rollcard .where { margin-top: 0; min-height: 0; }
  .rollcard .mapbox, .rollcard .contact { grid-column: 1 / -1; }
  .rows li { grid-template-columns: 1fr; gap: .1rem; }
}
@media (max-width: 480px) {
  .postlist .kind { display: none; }      /* on a phone the title needs the room */
  nav { display: flex; flex-wrap: wrap; gap: .15rem 1.1rem; }
  nav a { margin-left: 0; }
}

/* A phone held sideways: the map would fill the screen, so it scrolls away with the page instead. */
@media (max-height: 520px) {
  .worldmap { position: static; }
  .place { scroll-margin-top: 1rem; }
}
