:root {
  --max-width: 1100px;
  --border-color: #ddd;
  --accent: #2a5db0;
  --error-bg: #fdecea;
  --error-border: #f5c2c0;
  --text: #222;
  --muted: #666;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  background: #fafafa;
  /* Guard against a stray horizontal scrollbar from the gallery's
     full-bleed (100vw-based) breakout. */
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

.site-title {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text);
}

.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  margin-top: 0;
}

.deadline-note {
  color: var(--muted);
}

/* ---- Welcome / landing page ---- */

.welcome {
  max-width: 640px;
}

.welcome h1 {
  font-size: 2rem;
}

.welcome-description {
  font-size: 1.1rem;
  white-space: pre-wrap;
  margin-bottom: 1.5rem;
}

.button-link {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 0.5rem;
}

.button-link:hover {
  opacity: 0.9;
}

/* AI-credit quote, pinned to the bottom-left corner of the viewport on the
   welcome page. Fixed so it hugs the page edge regardless of content height. */
.ai-quote {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  max-width: 400px;
  margin: 0;
  z-index: 10;
}

.ai-quote blockquote {
  margin: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border-color);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
}

/* Initials trail behind the quote, right-aligned under it. */
.ai-quote figcaption {
  margin-top: 0.4rem;
  padding-left: 1rem;
  text-align: right;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--muted);
}

.error-box {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.error-box ul {
  margin: 0;
  padding-left: 1.25rem;
}

.submit-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 640px;
}

.submit-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

.submit-form input[type="text"],
.submit-form input[type="password"],
.submit-form textarea {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-weight: normal;
}

.media-choice {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
}

/* Tabbed media picker */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.tab {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  align-self: auto;
  margin-bottom: -1px; /* sit the tab's border on top of the tablist border */
}

.tab:hover {
  color: var(--text);
  opacity: 1;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.media-input {
  margin: 0 0 0.75rem;
}

.media-constraint {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Drag-and-drop zone */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 1.5rem 1rem;
  text-align: center;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #eef3fb;
}

.dropzone-text {
  margin: 0 0 0.6rem;
  color: var(--muted);
}

/* Neutral secondary button so it reads as "browse", not the primary submit. */
.browse-btn {
  font: inherit;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #f5f5f5;
  color: var(--text);
  cursor: pointer;
  align-self: auto;
}

.browse-btn:hover {
  background: #ececec;
  opacity: 1;
}

/* Selected-file preview list */
.file-preview {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-preview:empty {
  display: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #fff;
}

.file-thumb {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: #f0f0f0;
}

.file-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.file-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  color: var(--muted);
  font-size: 0.85rem;
}

.file-remove {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #eee;
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  align-self: center;
}

.file-remove:hover {
  background: #e6bcbc;
  opacity: 1;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

button,
.delete-btn {
  font: inherit;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  align-self: flex-start;
}

button:hover,
.delete-btn:hover {
  opacity: 0.9;
}

.delete-btn {
  background: #b02a2a;
}

/* ---- Gallery layout ---- */

.gallery-layout {
  display: flex;
  align-items: stretch;
  /* Break out of the centered, max-width .site-main so the sidebar can hug
     the true left edge of the page instead of floating in from a gutter. */
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-top: -1.5rem;    /* cancel .site-main's top padding */
  margin-bottom: -1.5rem; /* cancel .site-main's bottom padding */
  /* Fill the viewport height so the sidebar reads as a full left panel. */
  min-height: calc(100vh - 61px);
}

.sidebar-toggle-checkbox {
  display: none;
}

.sidebar-toggle-label {
  display: none;
}

/* Minimal-width left panel, pinned to the page's left edge, with a tinted
   background to break up the page. */
.sidebar {
  flex: 0 0 190px;
  width: 190px;
  background: #f0f1f4;
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 1rem;
  /* Pin below the sticky header and scroll the list on its own when there
     are more projects than fit the viewport. */
  position: sticky;
  top: 61px;
  align-self: flex-start;
  height: calc(100vh - 61px);
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-list a {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: #e2e4e9;
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.3;
}

.project-list a:hover {
  background: #d7dae1;
}

.project-list .proj-title {
  display: block;
  font-weight: 600;
}

.project-list .proj-author {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.project-list li.current a {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.project-list li.current .proj-author {
  color: rgba(255, 255, 255, 0.85);
}

.project-detail {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1.5rem 1.75rem 5.5rem;
}

/* Title and author share a baseline-aligned row; author keeps its regular
   weight/size and just moves up beside the title. */
.project-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.project-heading h1 {
  margin: 0;
}

.project-detail .author {
  color: var(--muted);
  margin: 0;
}

.description {
  white-space: pre-wrap;
}

.media-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.media-display video {
  max-width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 8px;
}

/* One-photo-at-a-time viewer: a fixed-size stage so every image, whatever
   its aspect ratio, is shown inside the same box (letterboxed, not cropped). */
.photo-viewer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.photo-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 70vh;
  /* Leave room for the header, heading/description above, the counter below,
     and the fixed Prev/Next bar, so the box never slides under them. */
  max-height: calc(100vh - 22rem);
  background: #f0f1f4;
  border-radius: 8px;
  overflow: hidden;
}

.photo-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.photo-slide.active {
  display: block;
}

.photo-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  align-self: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.photo-nav:hover {
  opacity: 0.9;
}

.photo-nav svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  display: block;
}

.photo-slide {
  cursor: zoom-in;
}

.photo-counter {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.75rem 0 0;
}

/* Fullscreen photo lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  background: rgba(0, 0, 0, 0.92);
}

.lightbox[hidden] {
  display: none;
}

body.lightbox-open {
  overflow: hidden;
}

/* The image is a flex item between the two arrows, so the arrows reserve
   their own space in the row and never overlap the photo. */
.lightbox-img {
  flex: 1 1 auto;
  min-width: 0;
  height: calc(100vh - 6rem);
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-nav,
.lightbox-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
}

.lightbox-nav:hover,
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
  opacity: 1;
}

.lightbox-nav {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  align-self: center;
}

.lightbox-nav svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
  display: block;
}

/* Close stays pinned to the top-right corner of the viewport. */
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  align-self: auto;
}

.lightbox-close svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  display: block;
}

.lightbox-counter {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
}

/* Prev/Next are anchored to the bottom corners of the viewport and styled
   as buttons. They float above the content; .gallery-layout reserves bottom
   padding so nothing hides behind them. */
.prev-next .prev-link,
.prev-next .next-link {
  position: fixed;
  bottom: 1.25rem;
  z-index: 20;
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* Anchored just to the right of the sidebar panel, so Previous sits in the
   content area rather than on top of the sidebar. */
.prev-next .prev-link {
  left: calc(190px + 1.25rem);
}

.prev-next .next-link {
  right: 1.25rem;
}

.prev-next a.prev-link:hover,
.prev-next a.next-link:hover {
  opacity: 0.9;
}

.prev-next .disabled {
  background: #d8d8d8;
  color: #f5f5f5;
  box-shadow: none;
  cursor: default;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem;
  text-align: left;
}

/* ---- Mobile ---- */

@media (max-width: 768px) {
  /* Let the quote flow after the content instead of pinning it, so it never
     covers the call-to-action on a short screen. */
  .ai-quote {
    position: static;
    max-width: none;
    margin-top: 2.5rem;
  }

  .gallery-layout {
    display: block;
    /* Drop the full-bleed breakout on mobile; content flows normally. */
    margin: 0;
    min-height: 0;
  }

  .project-detail {
    padding: 0 0 5rem;
  }

  /* Toggle button lives in the header bar (top-right), not on the page. It
     references the checkbox by id, so it toggles the drawer from anywhere. */
  .sidebar-toggle-label {
    display: inline-flex;
    align-items: center;
    position: fixed;
    top: 0.75rem;
    right: 1rem;
    z-index: 50;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
  }

  /* The project list opens as a dropdown anchored under the header. */
  .sidebar {
    display: none;
    position: fixed;
    top: 3.6rem;
    right: 0.75rem;
    left: auto;
    z-index: 45;
    width: auto;
    min-width: 200px;
    max-width: 80vw;
    max-height: 70vh;
    overflow-y: auto;
    flex: none;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 0.75rem 1rem;
    margin: 0;
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar {
    display: block;
  }

  .photo-stage {
    height: 50vh;
  }

  .photo-nav {
    width: 38px;
    height: 38px;
    font-size: 1.3rem;
  }

  /* Slightly tighter buttons on small screens so they don't crowd. */
  .prev-next .prev-link,
  .prev-next .next-link {
    bottom: 0.75rem;
    padding: 0.5rem 0.9rem;
  }

  .prev-next .prev-link {
    left: 0.75rem;
  }

  .prev-next .next-link {
    right: 0.75rem;
  }
}
