/* ============================================================
   Mark's Gallery — public stylesheet
   Gothenburg design system: Syne display, Plus Jakarta Sans body,
   teal-forward palette.
   ============================================================ */

:root {
    --ground:     #D3E0E4;   /* page (slightly deeper teal-grey) */
    --ink:        #15323A;   /* deep teal-ink text */
    --ink-soft:   #4A626B;   /* muted */
    --teal-deep:  #0F5C68;   /* primary deep teal */
    --teal:       #3D9BB5;   /* bright accent teal */
    --teal-link:  #1E6E83;   /* link teal */
    --surface:    #E4EDEF;   /* card surface */
    --surface-2:  #C8D9DD;   /* deeper surface */
    --border:     #A7BEC4;   /* borders (tealier) */
    --dark:       #062F37;   /* darkest teal (footer) */
    --dark-2:     #0A4750;   /* dark teal panel */
    --white:      #FFFFFF;

    --serif: 'Syne', sans-serif;
    --sans:  'Plus Jakarta Sans', sans-serif;

    /* aliases used by admin.css */
    --paper:       var(--ground);
    --field:       var(--white);
    --accent:      var(--teal);
    --accent-deep: var(--teal-deep);
    --hairline:    var(--border);
    --ink-faint:   #8AA2A9;
    --shadow:      rgba(15, 92, 104, 0.14);

    --gutter: clamp(1rem, 3.5vw, 2.5rem);
    --row-h: 240px;          /* original-view row height (desktop) */
    --gap: clamp(0.4rem, 1.2vw, 0.85rem);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    background: var(--ground);
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
img, video { display: block; max-width: 100%; }
a { color: var(--teal-link); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---- Masthead ---- */
.masthead {
    max-width: 1500px;
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 3.5rem) var(--gutter) clamp(1.25rem, 3vw, 2rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.masthead .tagline {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(0.82rem, 1.9vw, 1.05rem);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--teal-deep);
    text-align: left;
}
.masthead .insta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--teal-deep);
    flex-shrink: 0;
    transition: color 0.2s ease;
}
.masthead .insta-btn:hover { color: var(--teal); }

/* ---- Toolbar (legacy; unused now toggle removed) ---- */
.toolbar {
    max-width: 1500px;
    margin: 0 auto;
    padding: clamp(1.1rem, 2.5vw, 1.75rem) var(--gutter) 0;
    display: flex;
    justify-content: flex-end;
}
.view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.vt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--ink-faint);
    padding: 0.4rem;
    border-radius: 8px;
    line-height: 0;
    transition: color 0.2s ease;
}
.vt-btn svg { stroke: currentColor; }
.vt-btn:hover { color: var(--teal); }
.vt-btn.active { color: var(--teal-deep); }
.insta-btn { color: var(--ink-faint); }
.insta-btn:hover { color: var(--teal); }

/* ---- Gallery ---- */
.gallery {
    padding: clamp(1.1rem, 2.5vw, 1.75rem) var(--gutter) 5rem;
    max-width: 1500px;
    margin: 0 auto;
}

/* SQUARE view — uniform grid, cropped */
.grid[data-view="square"] {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}
.grid[data-view="square"] .tile-media {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}
.grid[data-view="square"] .tile-media img,
.grid[data-view="square"] .tile-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ORIGINAL view — same uniform square grid as square view, but each image
   sits inside its cell at its native aspect ratio (contained, not cropped).
   The grid stays regular; spacing within cells varies by image shape. */
.grid[data-view="original"] {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}
.grid[data-view="original"] .tile {
    background: transparent;
    box-shadow: none;
}
.grid[data-view="original"] .tile-media {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.grid[data-view="original"] .tile-media img,
.grid[data-view="original"] .tile-media video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 5px;
}

@media (max-width: 1100px) {
    .grid[data-view="square"], .grid[data-view="original"] { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
    .grid[data-view="square"], .grid[data-view="original"] { grid-template-columns: repeat(3, 1fr); }
    :root { --gap: 0.35rem; }
}

.tile {
    position: relative;
    background: var(--surface-2);
    border-radius: 7px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(15,92,104,0.22);
}
.tile-media { position: relative; }

.badge {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    background: rgba(15,92,104,0.78);
    display: grid;
    place-items: center;
    pointer-events: none;
}
.badge svg { width: 0.82rem; height: 0.82rem; fill: #fff; }

/* ---- Empty state ---- */
.empty {
    text-align: center;
    padding: 5rem var(--gutter);
    color: var(--ink-soft);
}
.empty .big {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--teal-deep);
    margin-bottom: 0.5rem;
}

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(211, 224, 228, 0.82);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    display: none;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.lightbox.open { display: block; }
/* Control bar above the media — plain icons + text, tracks image width */
.lb-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 auto 0.75rem;
}
.lb-controls-nav { display: inline-flex; gap: 1rem; }
.lb-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: none;
    background: none;
    color: #fff;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0;
    line-height: 1;
    transition: opacity 0.2s ease;
}
.lb-ctrl { color: var(--teal-deep); }
.lb-ctrl svg { stroke: currentColor; flex-shrink: 0; width: 14px; height: 14px; }
.lb-ctrl:hover { opacity: 0.7; }
.lb-ctrl[disabled] { opacity: 0.3; cursor: default; }

.lb-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: clamp(3.5rem, 7vw, 5rem) var(--gutter) 4rem;
}
.lb-stage {
    display: grid;
    place-items: center;
    margin-bottom: 1.25rem;
}
.lb-stage img, .lb-stage video {
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(15,50,60,0.15);
}
/* Hide the large centre play-button overlay that dims the first frame.
   The standard control bar at the bottom still appears on hover/tap. */
.lb-stage video::-webkit-media-controls-overlay-play-button { display: none; }
.lb-stage video::-webkit-media-controls-start-playback-button { display: none; }

/* Video first-frame still + custom play button (no browser dimming) */
.lb-video-wrap { position: relative; display: inline-block; line-height: 0; }
.lb-video-still {
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(15,50,60,0.15);
    pointer-events: none;
}
.lb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4.5rem;
    height: 4.5rem;
    border: none;
    border-radius: 50%;
    background: rgba(15, 92, 104, 0.82);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 4px;
    transition: background 0.2s ease, transform 0.2s ease;
}
.lb-play:hover { background: var(--teal-deep); transform: translate(-50%, -50%) scale(1.06); }
.lb-video-playing {
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(15,50,60,0.15);
}

.lb-panel {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    max-width: 640px;
    margin: 0 auto;
}
.lb-panel.expanded { padding: 0; }
.lb-caption:empty { display: none; }
.lb-location {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--teal-deep);
    text-decoration: none;
    transition: color 0.2s ease;
}
a.lb-location:hover { color: var(--teal); }
.lb-location svg { stroke: currentColor; flex-shrink: 0; }
.lb-caption a {
    color: var(--teal-deep);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.lb-caption a:hover { color: var(--teal); }

.lb-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}
.lb-date {
    font-family: var(--serif);
    font-size: 0.9rem;
    font-weight: 450;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--teal-deep);
    line-height: 1.3;
}
.lb-caption {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    line-height: 1.3;
    color: var(--teal-deep);
    margin: 0.6rem 0 0;
    text-align: left;
}

.rule { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }

/* Comments — compact, on the dark panel */
.comments { margin-top: 2rem; }
.comments-list { margin-bottom: 0.85rem; }
.comment {
    margin-bottom: 0.85rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.comment:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.comment-head { font-size: 0.82rem; }
.comment .who { font-weight: 600; color: var(--ink); font-size: 0.82rem; }
.comment .when { color: var(--ink-soft); font-size: 0.82rem; }
.comment .body { margin-top: 0.25rem; color: var(--ink); font-size: 0.82rem; line-height: 1.5; }

/* "Leave a note" trigger — plain text, right side */
.note-toggle {
    margin-left: auto;
    border: none;
    background: none;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
    color: var(--teal-deep);
    transition: color 0.2s ease;
}
.note-toggle:hover { color: var(--teal); }
.note-toggle[aria-expanded="true"] { color: var(--ink-soft); }

/* Compact comment form, revealed on demand */
.cform { margin-top: 1rem; }
.cform[hidden] { display: none; }
.cform .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 520px) { .cform .row { grid-template-columns: 1fr; } }
.cform input, .cform textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-family: var(--sans);
    font-size: 0.88rem;
    color: var(--ink);
    transition: border-color 0.2s ease;
}
.cform input::placeholder, .cform textarea::placeholder { color: var(--ink-faint); }
.cform input:focus, .cform textarea:focus { outline: none; border-color: var(--teal); }
.cform .field { margin-bottom: 0.6rem; }
.cform textarea { resize: vertical; min-height: 64px; }
.btn {
    border: none;
    background: var(--teal-deep);
    color: #fff;
    padding: 0.6rem 1.4rem;
    border-radius: 100px;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: opacity 0.2s ease;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-sm { padding: 0.5rem 1.2rem; font-size: 0.72rem; }

.notice { padding: 0.8rem 1rem; border-radius: 6px; font-size: 0.9rem; margin-top: 1rem; }
.notice.ok { background: #DCEAEA; color: #1E6E83; }
.notice.err { background: #F6E6E6; color: #8A3232; }

/* Footer */
.site-foot {
    background: none;
    text-align: center;
    padding: 2.5rem var(--gutter) 3rem;
    color: var(--ink-faint);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}
.site-foot p {
    font-family: var(--serif);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.lb-loading {
    text-align: center;
    color: var(--ink-soft);
    font-family: var(--serif);
    padding: 3rem;
}

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
