/* Default color palette; overridden per-install by an inline :root rule
   rendered from the settings table (see layout.html/image.html). The variables
   must live on :root, not *, so the inline override wins the cascade. */
:root {
    --theme-color: #f5bb00;
    --post-accent-color: #36558F;
    --gallery-accent-color: #D78A76;
}

/* Site-wide font */
* {
    font-family: "Playfair Display", serif;
    font-optical-sizing: auto;
    font-weight: normal;
    font-style: normal;
}

/* Layout setup */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
body > * {
    margin: 12px 22px 16px 12px;
    flex: initial;
}
main {
    flex: auto;
}

/* Site-wide header style */
header  {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding-bottom: 0.3em;
    color: var(--theme-color);
    border: 6px solid black;
    box-shadow: 10px 10px 0 0 var(--theme-color);
}
header h1 {
    font-weight: bold;
    text-decoration: underline;
    text-decoration-thickness: 4px;
    text-decoration-color: var(--theme-color);
    color: black;
    margin-left: 12px;
    margin-right: 12px;
}
header h2 {
    font-weight: bold;
    text-decoration: underline;
    text-decoration-thickness: 4px;
    text-decoration-color: var(--theme-color);
    color: black;
    margin-left: 1em;
}
header nav menu {
    display: flex;
    list-style: none;
    padding: 0;
}
header nav menu li {
    margin: 12px 10px;
}
header nav menu li a {
    padding: 0 4px 2px 4px;
    text-decoration: none;
    font-size: 1.2em;
    border: 4px solid black;
    box-shadow: 5px 5px 0 0 var(--theme-color);
    color: black;
}
header nav menu li a:visited {
    color: black;
}
header nav menu li a:hover {
    border: 4px solid var(--theme-color);
    box-shadow: 5px 5px 0 0 black;
    color: black;
}
#current {
    border: 4px solid var(--theme-color);
    box-shadow: 5px 5px 0 0 black;
    color: black;
}
#current:hover {
    border: 4px solid var(--theme-color);
    box-shadow: 5px 5px 0 0 black;
    color: black;
}

/* Site-wide footer style */
footer {
    border: 6px solid black;
    box-shadow: 10px 10px 0 0 var(--theme-color);

}
footer address {
    margin: 8px 12px;
}
footer address a {
    text-decoration: underline;
    text-decoration-color: var(--theme-color);
    text-decoration-thickness: 2px;
    color: black;
}

/* Home-page styling */
#home {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
}
#home article {
    max-width: 22vw;
    height: auto;
    border: 6px solid black;
    margin: 0 0 0.6cm 0 !important;
}
@media (orientation: portrait), (max-width: 12cm) {
    #home article {
        max-width: 96vw;
    }
}
#home article img {
    border-bottom: 2px solid black;
}
#home article hgroup {
    margin: 0 6px 4px 6px;
}
#home article hgroup h2 {
    font-size: 1.1em;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    display: inline;
}
#home article hgroup .date {
    display: inline;
    color: #484848;
}
#home article hgroup p {
    font-size: 0.9em;
}

#home .post {
    box-shadow: 10px 10px 0 0 var(--post-accent-color);
}
#home .post hgroup h2 {
    text-decoration-color: var(--post-accent-color);
}

#home .gallery a {
    text-decoration: none;
    color: black;
}
#home .gallery {
    box-shadow: 10px 10px 0 0 var(--gallery-accent-color);
}
#home .gallery hgroup h2 {
    text-decoration-color: var(--gallery-accent-color);
}

/* Gallery-page styling */
#gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0 0 0 12px;
}
#gallery article {
    margin: 0;
}
#gallery article a img {
    max-width: 32vw;
    height: auto;
    margin: 0 0.2cm 0.2cm 0;
    border: 6px solid black;
}
@media (orientation: portrait), (max-width: 12cm) {
    #gallery {
        justify-content: space-between;
    }
    #gallery article a img {
        max-width: 96vw;
    }
}

/* Single image view */
#image-view {
    display: grid;
    height: 100dvh;
    width: 100vw;
    margin: 0;
    row-gap: 0;
    column-gap: 0;
}
#image-view > * {
    margin: 0;
}
#image-view #image {
  /* fallbacks for older browsers */
  max-width: 100%;
  max-height: 100%;
  /* logical equivalents */
  max-inline-size: 100%;
  max-block-size: 100%;
  width: auto;
  height: auto;
  object-fit: contain; /* harmless if width/height are auto */
  display: block;      /* avoids any stray inline spacing */
}
#image-view a {
    text-decoration: none;
    color: black;
}
@media (orientation: landscape) {
    #image-view {
        grid-template-columns: 2cm minmax(0, 1fr) 2cm; /* was 1fr */
        grid-template-rows: 2cm minmax(0, 1fr) 2cm;    /* was 1fr */
    }
    #image {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
        place-self: center;
    }
    #next {
        grid-column-start: 3;
        grid-column-end: 4;
        grid-row-start: 2;
        grid-row-end: 3;
        margin-right: 0.5cm;
        font-size: 4em;
        text-align: right;
        place-content: center;
    }
    #prev {
        grid-column-start: 1;
        grid-column-end: 2;
        grid-row-start: 2;
        grid-row-end: 3;
        font-size: 4em;
        margin-left: 0.5cm;
        vertical-align: center;
        place-content: center;
    }
    #back {
        grid-column-start: 2;
        grid-column-end: 3;
        grid-row-start: 1;
        grid-row-end: 2;
        text-align: center;
        font-size: 2em;
    }
}
@media (orientation: portrait) {
    #image-view {
        grid-template-columns: 1fr 1fr;                 /* columns are fine */
        grid-template-rows: minmax(0, 1fr) 2cm 2cm 2cm; /* was 1fr */
    }
    #image {
        grid-column: 1 / 3;
        grid-row: 1 / 2;
        place-self: center;
    }
    #next {
        grid-column-start: 2;
        grid-column-end: 3;
        grid-row-start: 2;
        grid-row-end: 3;
        place-content: center;
        text-align: center;
        font-size: 4em;
    }
    #prev {
        grid-column-start: 1;
        grid-column-end: 2;
        grid-row-start: 2;
        grid-row-end: 3;
        place-content: center;
        text-align: center;
        font-size: 4em;
    }
    #back {
        grid-column-start: 1;
        grid-column-end: 3;
        grid-row-start: 3;
        grid-row-end: 4;
        place-content: center;
        text-align: center;
        font-size: 2em;
        margin-top: 1cm;
    }
}

/* Admin login */
#admin-login input {
    margin: 10px 0;
}

/* Cover image selection on edit gallery page */
#edit-gallery .cover-select {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .5rem;
}
#edit-gallery .cover-select label {
    display: block;
    border: 4px solid transparent;
    cursor: pointer;
}
#edit-gallery .cover-select label:has(input:checked) {
    border-color: var(--theme-color);
}
#edit-gallery .cover-select input[type="radio"] {
    position: absolute;
    opacity: 0;
}
#edit-gallery .cover-select img {
    width: 100%;
    height: auto;
    display: block;
}
#edit-gallery .cover-select .auto-cover span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100px;
    background: #eee;
    text-align: center;
}

/* Admin page */
#admin table {
    text-align: left;
    border-collapse: collapse;
}
#admin table tr td {
    padding-right: 50px;
}
#admin thead tr {
    border-bottom: 1px solid black;
}
#admin tbody tr:hover {
    background-color: lightgray;
}