/* Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-color: #f6f6f6;
  --sidebar-bg: #ffffff;
  --text-dark: #555d62;
  --text-muted: #a7a7a7;
  --text-hover: #333333;
  --sidebar-width: 260px;
}

html, body {
  height: 100%;
  font-family: 'Open Sans', sans-serif;
  font-weight: 300;
  color: var(--text-dark);
  background-color: var(--bg-color);
}

body {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Layout */
#public-site {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-content {
  padding: 60px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.site-name {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 26px;
  font-weight: 300;
  letter-spacing: 0.12em;
  line-height: 1.25;
  margin-bottom: 48px;
  text-transform: lowercase;
  color: var(--text-dark);
}

.site-name a {
  display: block;
}

.site-name a:hover {
  color: var(--text-hover);
}

.projects-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 80px;
}

.nav-link {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  transition: all 0.2s;
  padding: 2px 0;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-dark);
  border-bottom: 1px solid var(--text-dark);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
}

.footer-link {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.footer-link:hover {
  color: var(--text-dark);
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  height: 100vh;
  overflow-y: auto;
  position: relative;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
}

.view.active {
  display: flex;
}

/* Home / Cover View */
#home-view {
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.cover-container {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-image {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1s ease-in-out;
  cursor: pointer;
  /* Prevent easy downloading */
  user-select: none;
  -webkit-user-drag: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
}

.cover-image.active {
  opacity: 1;
  position: relative;
}

.carousel-dots {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(85, 93, 98, 0.3);
  cursor: pointer;
  transition: background-color 0.3s;
}

.carousel-dot.active {
  background-color: rgba(85, 93, 98, 0.7);
}

/* Project mosaic: aspect-driven collage with 14px gaps.
   Top padding sits just slightly above the site name in the left nav (60px). */
#project-view.view {
  display: none;
  padding: 54px 24px 36px;
}

#project-view.view.active {
  display: block;
}

.mosaic {
  position: relative;
  width: 100%;
}

.mosaic-item {
  position: absolute;
  overflow: hidden;
  background-color: #ececec;
  box-sizing: border-box;
}

.project-grid .mosaic-item,
.grid-item {
  cursor: pointer;
}

.mosaic-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.2s;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.project-grid .mosaic-item:hover img {
  opacity: 0.9;
}

/* Transparent overlay to prevent easy right-click download on the public grid */
.project-grid .mosaic-item::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
}

.mosaic-edit.file-drag {
  outline: 1px dashed var(--text-dark);
  outline-offset: 4px;
}

.mosaic-tools {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 8px;
  background: linear-gradient(to bottom, rgba(20, 20, 20, 0.4), transparent 55%);
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 2;
  pointer-events: none;
}

.mosaic-item.is-editable:hover .mosaic-tools,
.mosaic-item.is-editable:focus-within .mosaic-tools {
  opacity: 1;
}

.mosaic-tools > * {
  pointer-events: auto;
}

.mosaic-size-wrap {
  margin: 0;
}

.mosaic-size {
  font-family: inherit;
  font-size: 11px;
  padding: 4px 6px;
  border: 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-dark);
  max-width: 118px;
  cursor: pointer;
}

.mosaic-icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.mosaic-icon-btn:hover {
  background: #fff;
  color: #a33;
}

.mosaic-item.dragging {
  opacity: 0.45;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Image Viewer — stays in the main content area; left sidebar remains visible */
#image-view {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 54px 32px 24px;
  cursor: default;
}

.image-viewer {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.viewer-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  cursor: pointer;
}

.viewer-image {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.image-caption {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-height: 16px;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}

.control-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 8px 12px;
  transition: color 0.2s;
}

.control-btn:hover {
  color: var(--text-dark);
}

.image-counter {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Bio / Contact Views */
#bio-view,
#contact-view {
  padding: 80px 100px;
  max-width: 800px;
}

.bio-content h2,
.contact-content h2 {
  font-size: 32px;
  font-weight: 400;
  margin-bottom: 40px;
  letter-spacing: 1px;
}

.bio-content p,
.contact-content p {
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 20px;
  color: var(--text-muted);
}

.contact-info {
  margin: 40px 0;
}

.contact-info p {
  margin-bottom: 12px;
}

.contact-info a {
  border-bottom: 1px solid var(--text-muted);
  transition: color 0.2s;
}

.contact-info a:hover {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark);
}

.social-links {
  display: flex;
  gap: 20px;
  margin-top: 30px;
}

.social-links a {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

.social-links a:hover {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark);
}

/* Admin Styles */
#admin-site {
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-color);
  overflow: auto;
}

.admin-view {
  display: none;
}

.admin-view.active {
  display: block;
}

/* Login */
.login-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 40px;
  background: white;
  border-radius: 4px;
}

.login-container h1 {
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 30px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-dark);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-family: inherit;
  font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--text-dark);
}

.btn-primary,
.btn-secondary,
.btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--text-dark);
  color: white;
}

.btn-primary:hover {
  background-color: var(--text-hover);
}

.btn-secondary {
  background-color: #e0e0e0;
  color: var(--text-dark);
}

.btn-secondary:hover {
  background-color: #d0d0d0;
}

.btn-danger {
  background-color: #c44;
  color: white;
}

.btn-danger:hover {
  background-color: #a33;
}

.error-message {
  color: #c44;
  font-size: 12px;
  margin-top: 10px;
  min-height: 16px;
}

/* Admin Dashboard */
.admin-nav {
  background: white;
  padding: 20px 40px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 30px;
}

.admin-nav h1 {
  font-size: 20px;
  font-weight: 400;
  margin-right: auto;
}

.admin-tabs {
  display: flex;
  gap: 10px;
}

.admin-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.admin-tab:hover,
.admin-tab.active {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark);
}

.admin-panel {
  display: none;
  padding: 40px;
}

.admin-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.panel-header h2 {
  font-size: 22px;
  font-weight: 400;
}

.admin-list {
  display: grid;
  gap: 20px;
}

.admin-item {
  background: white;
  padding: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.admin-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.admin-item-actions {
  display: flex;
  gap: 10px;
}

.settings-form {
  max-width: 600px;
  background: white;
  padding: 30px;
  border-radius: 4px;
}

.settings-form textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

.settings-section + .settings-section {
  margin-top: 36px;
  padding-top: 30px;
  border-top: 1px solid #eee;
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 400;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.save-status {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

.save-status.success {
  color: #3a7a4a;
}

.save-status.error {
  color: #c44;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  overflow: auto;
}

.modal.active {
  display: block;
}

.modal-content {
  background-color: white;
  margin: 50px auto;
  padding: 40px;
  width: 94%;
  max-width: 1100px;
  border-radius: 4px;
  position: relative;
}

.modal-close {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 28px;
  font-weight: 300;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-dark);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.photo-dropzone {
  border: 1px dashed #ccc;
  border-radius: 4px;
  padding: 22px 16px;
  text-align: center;
  color: var(--text-muted);
  margin: 12px 0 4px;
  transition: border-color 0.2s, background 0.2s;
}

.photo-dropzone p {
  margin-bottom: 10px;
  font-size: 13px;
}

.photo-dropzone.dragover {
  border-color: var(--text-dark);
  background: #f0f0f0;
}

.admin-photo-item {
  background: #f6f6f6;
  border-radius: 4px;
  overflow: hidden;
  cursor: grab;
  display: flex;
  flex-direction: column;
  border: 1px solid #ececec;
}

.admin-photo-item.dragging {
  opacity: 0.45;
}

.admin-photo-preview {
  background: #e8e8e8;
  min-height: 110px;
  max-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.admin-photo-preview img {
  max-width: 100%;
  max-height: 164px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.admin-photo-meta {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-photo-size-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.admin-photo-size-label select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-dark);
  background: white;
}

.admin-photo-actions {
  display: flex;
  gap: 6px;
}

.admin-photo-actions .btn-secondary,
.admin-photo-actions .btn-danger {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  background-color: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-item:hover .photo-item-actions {
  opacity: 1;
}

.photo-action-btn {
  background: rgba(255,255,255,0.9);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 200px;
  }
  
  .sidebar-content {
    padding: 40px 30px;
  }
  
  .site-name {
    font-size: 22px;
    letter-spacing: 0.1em;
    margin-bottom: 36px;
  }
  
  #home-view {
    padding: 30px;
  }

  #project-view.view.active,
  #image-view {
    padding: 34px 16px 24px;
  }
  
  #bio-view,
  #contact-view {
    padding: 60px 40px;
  }
}

@media (max-width: 480px) {
  #public-site {
    flex-direction: column;
  }
  
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
  }
  
  .sidebar-content {
    padding: 30px 20px;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    height: auto;
    min-height: 100vh;
  }
  
  .site-name {
    font-size: 28px;
    letter-spacing: 0.12em;
  }

  #project-view.view.active,
  #image-view {
    padding: 24px 14px 20px;
  }
  
  #bio-view,
  #contact-view {
    padding: 40px 20px;
  }
}