/* style.css — mcinsta */

:root {
  --bg:          #fafafa;
  --surface:     #ffffff;
  --ink:         #1a1a1a;
  --ink-soft:    #555;
  --ink-faint:   #8a8a8a;
  --line:        #e8e6e1;
  --accent:      #d23f3f;
  --accent-soft: #fbeaea;
  --link:        #2a5dba;
  --radius:      14px;
  --container:   620px;
  --max-feed:    560px;
  --shadow:      0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250,250,250,.92);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--container);
  margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand {
  font-family: "Snell Roundhand", "Brush Script MT", "Apple Chancery", cursive;
  font-size: 28px; font-weight: 700; letter-spacing: .5px; color: var(--ink);
}
.topnav { display: flex; align-items: center; gap: 10px; }
.topnav-user { display: flex; align-items: center; gap: 8px; }

.container { max-width: var(--container); margin: 0 auto; padding: 16px 16px 80px; }
.feed { max-width: var(--max-feed); margin: 0 auto; display: grid; gap: 24px; }

.footer {
  border-top: 1px solid var(--line);
  padding: 24px; text-align: center; color: var(--ink-faint); font-size: 13px;
}

.btn, .btn-primary, .btn-ghost {
  display: inline-block; cursor: pointer;
  padding: 9px 14px; border-radius: 999px;
  font: inherit; font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.btn { background: var(--ink); color: #fff; }
.btn:hover { text-decoration: none; opacity: .92; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); text-decoration: none; }
.btn-text { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--ink-soft); }
.btn-text.danger { color: var(--accent); }
.btn-text.small { font-size: 14px; }
button[disabled] { opacity: .55; cursor: not-allowed; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; background: var(--line); border: 1px solid var(--line);
}
.avatar-sm { width: 26px; height: 26px; }
.avatar-lg { width: 88px; height: 88px; border-width: 2px; }

.post {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.post-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.post-author { display: flex; align-items: center; gap: 10px; }
.author-name { font-weight: 600; }
.post-time { font-size: 13px; color: var(--ink-faint); }

/* Single-image posts and carousel slides share the same aspect-ratio box
   so landscape and portrait photos both center nicely and every card has
   a consistent height. Aspect ratio ~4:5 (Instagram-esque). */
.post-image,
.carousel-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0eee9;
  aspect-ratio: 4 / 5;
  overflow: hidden;
}
.post-image img,
.carousel-slide img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  background: #f0eee9;
}

/* ---------- Carousel ---------- */
.carousel {
  position: relative;
  background: #f0eee9;
  overflow: hidden;
}
.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.carousel-counter {
  position: absolute;
  top: 10px; right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.carousel-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.85);
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: none; /* shown on desktop only */
  align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }
.carousel-nav[disabled] { opacity: .35; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .carousel:hover .carousel-nav { display: flex; }
}
.carousel-dots {
  position: absolute;
  bottom: 10px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.carousel-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  box-shadow: 0 0 2px rgba(0,0,0,.3);
  transition: background .15s, transform .15s;
}
.carousel-dot.active {
  background: #fff;
  transform: scale(1.3);
}

.post-actions { display: flex; align-items: center; gap: 16px; padding: 10px 14px 4px; font-size: 15px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 6px; cursor: pointer;
  color: var(--ink-soft); font: inherit; border-radius: 8px;
  transition: transform .12s, color .12s;
}
.like-btn:hover { color: var(--ink); }
.like-btn .heart { font-size: 20px; line-height: 1; }
.like-btn.liked { color: var(--accent); }
.like-btn.liked .heart { animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(1);} 50% { transform: scale(1.4);} 100% { transform: scale(1);} }

.comment-link { color: var(--ink-soft); }
.comment-link:hover { color: var(--ink); text-decoration: none; }

.caption { padding: 4px 14px 14px; }
.caption-author { font-weight: 600; margin-right: 6px; }

.comments { padding: 12px 14px 16px; border-top: 1px solid var(--line); }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin: 0 0 10px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; }
.comment { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.comment-body { font-size: 15px; }
.comment-author { font-weight: 600; margin-right: 6px; }
.comment-time { color: var(--ink-faint); font-size: 12px; margin-left: 8px; }
.comment-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.comment-form textarea {
  width: 100%; padding: 8px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; resize: vertical; background: #fff;
}

.inline-form { display: inline; }

.profile-head {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 18px;
  align-items: start;
  padding: 8px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.profile-name { margin: 0; font-size: 22px; }
.profile-username { color: var(--ink-faint); margin-bottom: 6px; }
.profile-bio { margin: 6px 0; }
.profile-stats { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.profile-edit { margin-top: 10px; }
.profile-edit summary { display: inline-block; list-style: none; cursor: pointer; }
.profile-edit summary::-webkit-details-marker { display: none; }
.profile-edit form { margin-top: 12px; max-width: 420px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #eee;
  overflow: hidden;
}
.grid-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.grid-item:hover img { transform: scale(1.03); }
.grid-multi-badge {
  position: absolute;
  top: 6px; right: 6px;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  pointer-events: none;
}
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
}

.stack { display: grid; gap: 12px; }
.stack label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); }
.label-text { font-size: 14px; color: var(--ink-soft); }
.stack input[type="text"],
.stack input[type="password"],
.stack textarea {
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.stack textarea { resize: vertical; }
.checkbox { flex-direction: row; align-items: center; display: flex; gap: 8px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--ink-faint); }
.small { font-size: 13px; }

/* ---------- Upload ---------- */
.upload-wrap h1 { margin-top: 0; }

.picker-mobile { display: none; gap: 10px; }
.picker-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px 12px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.picker-btn:active { background: #faf8f3; border-color: var(--ink); }
.picker-btn input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.picker-icon { font-size: 32px; line-height: 1; }
.picker-label { font-weight: 600; font-size: 15px; }

.dropzone {
  display: block;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 24px; cursor: pointer; position: relative;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--ink); background: #fbf8f2; }
.dropzone input[type="file"] { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.dropzone-inner { display: grid; gap: 8px; place-items: center; pointer-events: none; }
.dropzone-icon { font-size: 36px; }
.dropzone-text strong { display: block; }

#preview-wrap {
  display: grid; gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.preview-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.preview-item {
  position: relative;
  flex: 0 0 auto;
  width: 96px; height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: #eee;
  scroll-snap-align: start;
  touch-action: none; /* let the pointer drag logic take over */
  transition: transform .2s;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.preview-item.dragging {
  cursor: grabbing;
  opacity: 0.9;
  transition: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transform-origin: center;
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.preview-pos {
  position: absolute;
  bottom: 4px; left: 4px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  pointer-events: none;
}
.preview-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.preview-hint { margin: 0; }

@media (max-width: 640px) {
  .picker-mobile { display: flex; }
  .picker-desktop { display: none; }
}

.login-wrap { max-width: 360px; margin: 32px auto; }

.flash {
  padding: 10px 14px; margin-bottom: 14px;
  background: #eef7e9; border: 1px solid #cce6c2; color: #2d6a1c;
  border-radius: 10px; font-size: 14px;
}
.error {
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid #f0c8c8; color: #8a2222;
  border-radius: 10px; font-size: 14px;
}
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.pager { display: flex; justify-content: space-between; padding: 18px 4px; }

@media (max-width: 420px) { .hide-sm { display: none; } }

/* ---------- Admin ---------- */
/* Admin page overrides the narrow feed container so tables can breathe. */
body.wide main.container { max-width: 1100px; }

.admin-wrap h1 { margin-top: 0; }
.admin-wrap h2 { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 18px; }
.admin-wrap h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin: 20px 0 8px; }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { background: #faf8f3; font-weight: 600; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .num { text-align: right; }
.admin-table .row-actions { white-space: nowrap; }
.admin-table summary {
  cursor: pointer; display: inline-block;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; list-style: none;
}
.admin-table summary::-webkit-details-marker { display: none; }
.admin-table summary:hover { background: #faf8f3; }

.edit-panel {
  margin-top: 10px; padding: 12px;
  background: #faf8f3; border-radius: 10px;
  display: grid; gap: 14px; min-width: 240px;
}
.edit-panel form { margin: 0; }
.edit-panel input[type="text"], .edit-panel input[type="password"] { width: 100%; }
.edit-panel input.full { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

.admin-form { max-width: 520px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .grid-2 { grid-template-columns: 1fr; } }

.flash-pre { margin: 0; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.ok { color: #2d6a1c; font-weight: 600; }
