/* ---------- Design tokens ---------- */
:root {
  --text: #1f1d1a;
  --text-muted: #6b6359;
  --bg: #fbf9f5;
  --accent: #7a5a9e;
  --rule: #e6ddd0;

  --font-serif: Charter, "Iowan Old Style", "Source Serif Pro",
                Georgia, Cambria, "Times New Roman", Times, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI",
               Inter, Roboto, "Helvetica Neue", Arial, sans-serif;

  --measure: 34rem;         /* ~65 characters per line */
  --step: 1.25rem;          /* vertical rhythm */
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.125rem;       /* 18px */
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Layout ---------- */
main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem 1.25rem 5rem;
}

section { margin-top: 3rem; }

section + section {
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
}

/* ---------- Typography ---------- */
h1, h2 {
  font-family: var(--font-sans);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 {
  font-size: 2rem;
  margin: 0 0 0.25rem;
  font-weight: 700;
}

h2 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

p { margin: 0 0 var(--step); }

.byline {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.intro p:first-child::first-line { font-variant: small-caps; }

em, cite { font-style: italic; }

blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

blockquote p { margin-bottom: 0.5rem; }
blockquote p:last-child { margin-bottom: 0; }

.signoff {
  font-family: var(--font-sans);
  color: var(--text-muted);
  margin-top: 2rem;
}

.postscript {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--text-muted);
}

.postscript-label {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-right: 0.35rem;
  color: var(--text);
}

.postscript a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.postscript a:hover { text-decoration-thickness: 2px; }

/* ---------- Images (for when you add them) ---------- */
img,
figure {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2rem auto;
  border-radius: 4px;
}

figure { margin-inline: 0; }

figure img { margin: 0; }

figcaption {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

/* ---------- Inline link style ---------- */
a.lightbox-trigger {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}
a.lightbox-trigger:hover { text-decoration-thickness: 2px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 8, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow-y: auto;
}

.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }

.lightbox-content {
  max-width: 860px;
  width: 100%;
  margin: auto;
}

.lightbox-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.lightbox-figure {
  margin: 0;
  background: #fff;
  padding: 10px;
  border-radius: 3px;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.5);
}

.lightbox-figure img {
  width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  object-fit: cover;
  object-position: center;
  display: block;
  margin: 0;
  border-radius: 0;
}

.lightbox-caption {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.55;
  color: #f5efe3;
  max-width: 44rem;
  margin: 0 auto;
  text-align: center;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.lightbox-close:hover { background: #fff; }

@media (max-width: 32rem) {
  .lightbox-images { grid-template-columns: 1fr; }
}

/* ---------- Photo pile ---------- */
.photo-pile {
  display: grid;
  place-items: center;
  margin: 3rem auto 2rem;
  padding: 1.5rem 0;
  min-height: 280px;
}

.pile-photo {
  grid-area: 1 / 1;
  width: 62%;
  max-width: 280px;
  height: auto;
  background: #fff;
  padding: 10px 10px 14px;
  border-radius: 2px;
  margin: 0;
  cursor: pointer;
  box-shadow: 0 10px 22px -8px rgba(0, 0, 0, 0.3),
              0 2px 4px rgba(0, 0, 0, 0.08);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.pile-photo:nth-child(1) { transform: rotate(-7deg) translate(-38%, -4%); z-index: 1; }
.pile-photo:nth-child(2) { transform: rotate(3deg)  translate(-2%, 6%);   z-index: 3; }
.pile-photo:nth-child(3) { transform: rotate(6deg)  translate(38%, -2%);  z-index: 2; }

.pile-photo:hover { z-index: 10; }

.pile-photo.is-selected {
  transform: rotate(0deg) scale(1.08);
  z-index: 20;
  box-shadow: 0 16px 32px -10px rgba(0, 0, 0, 0.35),
              0 4px 8px rgba(0, 0, 0, 0.1);
}

@media (max-width: 32rem) {
  .photo-pile { min-height: 220px; padding: 1rem 0; }
  .pile-photo { width: 58%; }
  .pile-photo:nth-child(1) { transform: rotate(-6deg) translate(-30%, -3%); }
  .pile-photo:nth-child(3) { transform: rotate(5deg)  translate(30%, -1%); }
}

@media (prefers-color-scheme: dark) {
  .pile-photo {
    background: #ece7df;
    box-shadow: 0 10px 22px -8px rgba(0, 0, 0, 0.6),
                0 2px 4px rgba(0, 0, 0, 0.3);
  }
}

/* ---------- Device mockup ---------- */
.device {
  --device-width: 280px;
  --device-radius: 34px;
  --frame-color: #3d3328;     /* darkened warm variant of --bg */
  --screen-bg: #f1eadd;

  margin: 3rem auto 2.5rem;
  max-width: var(--device-width);
  padding: 0;
  transform: rotate(-4deg);
  transform-origin: center center;
}

.device-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 17;
  background: var(--screen-bg);
  border: 16px solid var(--frame-color);
  border-radius: var(--device-radius);
  overflow: hidden;
  box-shadow: 0 28px 44px -12px rgba(45, 30, 15, 0.45),
              0 10px 18px -6px rgba(45, 30, 15, 0.25);
}

/* Home indicator */
.device-screen::after {
  content: "";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 3px;
  z-index: 5;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.screen[hidden] { display: none; }

.screen-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  border-radius: 0;
}

.screen--photo { background: #fff; }
.screen--photo .screen-image { object-fit: contain; }

/* Lock screen overlay */
.screen--lock { cursor: pointer; }

.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px 28px;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0) 35%,
    rgba(0, 0, 0, 0) 65%,
    rgba(0, 0, 0, 0.55) 100%
  );
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.lock-time { text-align: center; }

.lock-hours {
  font-family: var(--font-sans);
  font-size: 3rem;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.02em;
}

.lock-date {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  margin-top: 0.35rem;
  opacity: 0.9;
}

/* Navigation arrows */
.nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.85);
  color: #111;
  font-family: var(--font-sans);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  z-index: 4;
  transition: transform 0.1s ease, background 0.15s ease;
}

.nav-button:hover { background: #fff; }
.nav-button:active { transform: translateY(-50%) scale(0.94); }

.nav-button--next { right: 8px; }
.nav-button--prev { left: 8px; }

/* Messages-style badge at top-center of the photo screen */
.screen-badge {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  z-index: 4;
  pointer-events: none;
}

/* Comments screen */
.screen--comments {
  background: var(--bg);
  color: var(--text);
}

.comments-scroll {
  position: absolute;
  inset: 0;
  padding: 18px 16px 60px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Faux post header */
.post-header { margin-bottom: 0.85rem; }

.post-title {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.65rem;
  color: var(--text);
}

.post-byline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9b8df, #e8cdbd);
  flex-shrink: 0;
}

.byline-name {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.byline-meta {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* Skeleton loading placeholder for the post body */
.post-skeleton {
  margin: 0.5rem 0 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.skeleton-line {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 0%,
    rgba(0, 0, 0, 0.11) 50%,
    rgba(0, 0, 0, 0.06) 100%
  );
  background-size: 200% 100%;
  margin-bottom: 0.5rem;
  animation: skeleton-shimmer 2.2s ease-in-out infinite;
}

.skeleton-line--short { width: 55%; }
.skeleton-line--med   { width: 75%; }
.skeleton-gap { height: 0.6rem; }

@keyframes skeleton-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.comments-title {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.comment {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
}

.comment:first-of-type { border-top: 0; }

.comment--reply { padding-left: 1rem; }

.comment-author {
  font-weight: 600;
  margin-bottom: 0.15rem;
  font-size: 0.8rem;
}

.comment-meta {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.comment p { margin: 0; }

.comment-quote {
  margin: 0.35rem 0;
  padding: 0.25rem 0 0.25rem 0.6rem;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.device-caption {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  text-align: center;
}

@media (max-width: 32rem) {
  .device { --device-width: 240px; }
  .lock-hours { font-size: 2.4rem; }
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 32rem) {
  body { font-size: 1.0625rem; }          /* ~17px on small screens */
  main  { padding: 2rem 1rem 3.5rem; }
  h1    { font-size: 1.6rem; }
  h2    { font-size: 1.2rem; }
  section { margin-top: 2.25rem; }
  section + section { padding-top: 2.25rem; }
}

@media (min-width: 64rem) {
  body { font-size: 1.1875rem; }          /* ~19px on wide screens */
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #ece7df;
    --text-muted: #a59b8c;
    --bg: #1a1816;
    --accent: #b79fd9;
    --rule: #2f2a25;
  }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  section + section { border-top-color: #ccc; }
}
