@import url('https://font.swill.be/google/css/quicksand.css');
@import url('https://font.swill.be/google/css/averia-serif-libre.css');

/* ==========================================================================
   Base: layout, header and navigation, typography, photo links, footer
   (was layouts/base.njk)
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.6;
  color: #404040;
  background: #fff;
}

/* The photo blog (homepage, /blogs/photoblog), lofi and urbexing, feeds and posts, sit on
   light gray, so the photos' white frames stand out; the rest of the site is white */
html.tinted {
  background: #f4f4f4;
}

@media (prefers-color-scheme: dark) {
  html,
  html.tinted {
    color: #e0e0e0;
    background: #1a1a1a;
  }
}

body {
  /*font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;*/
  font-family: "Quicksand", sans-serif;
  font-weight: 400;
  font-style: normal;
}

header {
  padding: 4.5rem 0 1.5rem;
}

.header-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Lets the mobile menu drop onto its own row below logo + button */
  flex-wrap: wrap;
}

a.site-title {
  transform: rotate(-2deg) skew(-10deg);
  font-weight: 700;
  font-size: 1.8125rem;
  line-height: 1.2;
  display: inline-block;
  vertical-align: baseline;
  cursor: pointer;
  text-decoration: none !important;
  color: inherit;
}

.site-title:hover {
  opacity: 0.7;
}

nav {
  display: flex;
  gap: 2rem;
  align-items: center;
  /* On nav (not nav a) so the <span> dropdown toggles get it too */
  font-size: 0.85rem;
}

nav > ul {
  list-style: none;
  display: flex;
  gap: 2rem;
}

nav a {
  color: inherit;
  text-decoration: none;
  position: relative;
  display: block;
}

/* Hovered menu items get an underline (the chevron is inline-block, so it isn't underlined) */
nav a:hover,
nav .dropdown-toggle:hover {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.3em;
}

/* Dropdown styling */
nav li {
  position: relative;
}

/* Thin chevron drawn with two borders, rotated to point down */
nav .dropdown-toggle::after {
  content: '';
  display: inline-block;
  width: 0.26em;
  height: 0.26em;
  margin-left: 0.4em;
  border-right: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  transform: translateY(-0.22em) rotate(45deg);
}

nav .dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: transparent;
  list-style: none;
  /* As wide as the longest item, so a nested menu opens right beside it */
  width: max-content;
  white-space: nowrap;
  padding: 0.5rem 0;
  z-index: 1000;
  margin-top: 0;
}

/* Show menu on hover */
nav li:has(> .dropdown-toggle):hover > .dropdown-menu {
  display: block;
}

nav .dropdown-menu a {
  display: block;
  padding: 0.5rem 0;
  text-decoration: none;
}

/* Nested dropdown styling */
nav .dropdown-menu li {
  position: relative;
}

nav .dropdown-menu .dropdown-menu {
  position: absolute;
  left: 100%;
  top: 0;
  /* Gap as left padding (not margin) so the hover isn't lost crossing it.
     No top padding, so the first item lines up with its parent item. */
  padding: 0 0 0.5rem 1.25rem;
  z-index: 1001;
  margin-left: 0;
  margin-top: 0;
}

nav .dropdown-menu li:hover > .dropdown-menu {
  display: block;
}

/* Nested menus: same chevron, pointing right */
nav .dropdown-menu .dropdown-toggle::after {
  transform: translateY(-0.05em) rotate(-45deg);
}

/* Mobile menu button: "☰ Menu" */
.hamburger {
  display: none;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
}

.hamburger:hover {
  opacity: 0.7;
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hamburger-icon span {
  width: 14px;
  height: 1.5px;
  background: currentColor;
  display: block;
}

/* Mobile menu: opens in the page flow below logo + button, fully expanded */
nav.mobile-menu {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  /* nav centers its items by default; on mobile they line up with the logo */
  align-items: flex-start;
  margin-top: 1rem;
}

nav.mobile-menu.active {
  display: flex;
}

nav.mobile-menu ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

nav.mobile-menu a,
nav.mobile-menu .dropdown-toggle {
  display: block;
  padding: 0.4rem 0;
}

nav.mobile-menu .dropdown-toggle::after {
  display: none;
}

nav.mobile-menu .dropdown-menu {
  position: static;
  display: flex;
  min-width: auto;
  padding: 0;
  margin-left: 1.5rem;
}

/* Responsive: hide desktop nav, show hamburger on mobile/tablet */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  nav:not(.mobile-menu) {
    display: none !important;
  }
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
  font-size: 1rem;
}

/* Bullets/numbers line up with the text edge, item text is indented */
main :is(ul, ol) {
  padding-left: 1.25em;
  margin-bottom: 1rem;
}

/* Text sits in a narrower column than the photos */
main :is(h1, h2, h3, h4, h5, h6, p, ul, ol, blockquote, pre, .description, .tags, .post-tags, .post-meta, .meta, .feed-post > time, .feed-post > .date-link):not(.gallery *, figure *) {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* Quotes: a large bold quotation mark on the left, the text indented beside it */
main blockquote {
  position: relative;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  padding-left: 4.5rem;
  font-size: 1.15rem;
  line-height: 1.9;
}

main blockquote::before {
  content: "\201C";
  position: absolute;
  left: 0.75rem;
  top: 0.15em;
  font-family: "Quicksand", sans-serif;
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: #333;
}

main blockquote p:last-child {
  margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
  main blockquote::before {
    color: #ccc;
  }
}

/* Draft markers (preview builds only) */
main .draft-banner,
main .draft-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b45309;
}

main .draft-banner {
  padding: 0.5rem 1rem;
  border: 1px dashed #b45309;
  border-radius: 4px;
  text-align: center;
}

main .draft-label {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

main .feed-post > time {
  display: block;
}

footer {
  padding: 2rem 0;
  text-align: center;
  font-size: 0.9rem;
  color: #999;
  margin-top: 4rem;
}

footer a {
  color: inherit;
}

@media (prefers-color-scheme: dark) {
  footer {
    color: #666;
  }
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Averia Serif Libre", serif;
}

h1, h2, h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 400;
  line-height: 1.25;
}

h1 { font-size: 2.75rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }

p {
  margin-bottom: 1rem;
}

a {
  color: #0066cc;
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  a {
    color: #66b3ff;
  }
}

a:hover {
  opacity: 0.8;
}

/* Photo links: white border like an analog print, gentle zoom instead of fading.
   The border sits outside the overflow clip, so the zoom stays inside it. */
a:has(> img) {
  display: block;
  overflow: hidden;
  border: 10px solid #fff;
  border-radius: 2px;
  isolation: isolate;
}

a:has(> img):hover {
  opacity: 1;
}

a:has(> img) img {
  display: block;
  max-width: 100%;
  height: auto;
  transition: transform 0.4s ease;
}

/* A photo placed inline in a page's text (not in a gallery grid): the frame hugs
   the photo, centered, and never wider than the screen */
main :not(.gallery-item) > a:has(> img) {
  width: fit-content;
  max-width: 100%;
  margin: 2rem auto;
}

a:has(> img):hover img {
  transform: scale(1.04);
}

@media (prefers-reduced-motion: reduce) {
  a:has(> img) img,
  a:has(> img):hover img {
    transform: none;
    transition: none;
  }
}

/* ==========================================================================
   Feeds and posts: post entries, photo galleries, tags
   (was partials/post-entry-styles.njk)
   ========================================================================== */

/* Posts are separated by whitespace only, no lines */
.feed-post {
  margin-bottom: 4rem;
  padding-bottom: 3rem;
}

/* last-of-type, not last-child: on a post page the <article> is followed by other
   elements that would otherwise stop it counting as last */
.feed-post:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Untitled posts (lofi): the date is the link to the post */
.feed-post .date-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.feed-post .date-link:hover {
  text-decoration: underline;
}

/* Hidden on screen, still read by screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.feed-post h2 {
  margin: 0 0 0.5rem 0;
}

.feed-post h2 a {
  text-decoration: none;
  color: inherit;
}

.feed-post h2 a:hover {
  text-decoration: underline;
}

.feed-post time {
  color: #999;
  font-size: 0.95rem;
}

@media (prefers-color-scheme: dark) {
  .feed-post time {
    color: #666;
  }
}

/* As wide as a single landscape photo: 900px scaled image + 2 x 10px frame,
   so single photos and the two-column grid line up */
.gallery {
  max-width: 920px;
  margin: 2rem auto;
}

.gallery-item {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.gallery-item a {
  display: block;
}

/* A photo on its own row always fills the full gallery width, whatever its shape */
.gallery-item a.wide {
  grid-column: 1 / -1;
}

.gallery img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
}

@media (max-width: 600px) {
  .gallery-item {
    grid-template-columns: 1fr;
  }
}

.description {
  font-size: 1rem;
  margin: 1rem 0;
  color: #666;
  line-height: 1.6;
}

.description p {
  margin: 0 0 0.75rem;
}

.description p:last-child {
  margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
  .description {
    color: #aaa;
  }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #f0f0f0;
  border-radius: 1rem;
  text-decoration: none;
  font-size: 0.85rem;
}

@media (prefers-color-scheme: dark) {
  .tag {
    background: #333;
  }
}

/* Text of a page or post body, below its title (page, project and text-post layouts) */
.post-body {
  margin-top: 2rem;
  line-height: 1.8;
}

/* Intro paragraph under a project's title */
.lead {
  font-size: 1.1rem;
  margin: 1rem 0;
}

/* Intro text above a feed (FEED_INTRO_PAGES) */
.feed-intro {
  margin-bottom: 2rem;
}

/* ==========================================================================
   Home feed: the paginated photo blog, lofi, found art, writing (home-feed.njk)
   ========================================================================== */

.home-feed {
  max-width: 1000px;
  margin: 0 auto;
}

.home-feed > h1 {
  margin-bottom: 3rem;
}

/* Pagination styles */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin: 3rem 0 1rem 0;
  padding-top: 2rem;
  border-top: 1px solid #eee;
}

@media (prefers-color-scheme: dark) {
  .pagination {
    border-top-color: #333;
  }
}

.pagination a {
  text-decoration: none;
  color: #0066cc;
  font-weight: 500;
}

@media (prefers-color-scheme: dark) {
  .pagination a {
    color: #66b3ff;
  }
}

.pagination a:hover {
  text-decoration: underline;
}

.page-info {
  font-size: 0.9rem;
  color: #666;
}

@media (prefers-color-scheme: dark) {
  .page-info {
    color: #aaa;
  }
}

/* ==========================================================================
   Homepage: the latest posts of each section (home.njk)
   ========================================================================== */

/* Heading links in the homepage sections: not underlined */
.section-link {
  text-decoration: none;
}

.collection-section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
}

.collection-section h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.post-item h3 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.post-item time {
  font-size: 0.9rem;
  color: #999;
}

@media (prefers-color-scheme: dark) {
  .post-item time {
    color: #666;
  }
}

.post-item .excerpt {
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-size: 0.95rem;
  color: #666;
}

@media (prefers-color-scheme: dark) {
  .post-item .excerpt {
    color: #aaa;
  }
}

/* ==========================================================================
   /now/ page (now-feed.njk)
   ========================================================================== */

.now-feed {
  max-width: 800px;
  margin: 0 auto;
}

.feed-post .content {
  margin-top: 1rem;
  line-height: 1.8;
}

/* Wider spacing and smaller dates than the feeds (the global .feed-post rules above) */
.now-feed .feed-post {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
}

.now-feed .feed-post:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.now-feed .feed-post time {
  font-size: 0.9rem;
}

/* ==========================================================================
   Tag page (tags.njk, not rendered by build.js yet)
   ========================================================================== */

.tag-name {
  color: #c41e3a;
}

.tag-results {
  margin-top: 2rem;
}

.tag-count {
  color: #666;
  margin-bottom: 2rem;
}

.tag-post-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.tag-post {
  padding-bottom: 1.5rem;
}

.tag-post-title {
  margin: 0 0 0.5rem 0;
}

.tag-post-title a {
  color: #0066cc;
  text-decoration: none;
}

.tag-post-meta {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.tag-post-tags {
  margin-left: 1rem;
}

.tag-post-tags a {
  color: #666;
  text-decoration: none;
  margin-right: 0.5rem;
}

/* ==========================================================================
   Error pages: 404 and 50x (404.njk, 50x.njk)
   ========================================================================== */

.row {
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
}

@media all and (min-width: 420px) {
  .row {
    flex-direction: row;
    justify-content: space-between;
  }
}

.row .img-col img {
  max-width: 100%;
  height: auto;
}

@media all and (min-width: 420px) {
  .row .img-col img {
    width: 300px;
  }
}
