/* PostaPaint — gallery-white walls, one vermilion accent, exhibition-green card wall */

:root {
  --paper: #ffffff;
  --ink: #1b1b16;
  --stone: #6e6a60;
  --hairline: #e5e2da;
  --mat: #fbfaf6;
  --wall: #24413b;
  --wall-text: #f2efe4;
  --red: #c2321e;
  --serif: 'Libre Caslon Display', Georgia, serif;
  --serif-text: 'Libre Caslon Text', Georgia, serif;
  --sans: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

img { max-width: 100%; }
a { color: inherit; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--red); }

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- signage ---------- */

.wordmark {
  font-family: var(--sans);
  font-stretch: 125%;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.85rem;
  text-decoration: none;
}

.eyebrow, .field-label, .work-source, .badge, .chip {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
}

/* ---------- header / footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--hairline);
}

.site-header nav { display: flex; align-items: center; gap: 20px; font-size: 0.9rem; }
.site-header nav button { text-decoration: underline; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
.site-header nav button:hover { text-decoration-color: var(--red); }
.me { color: var(--stone); }

.site-footer {
  border-top: 1px solid var(--hairline);
  margin-top: 80px;
  padding: 24px clamp(16px, 4vw, 48px);
  color: var(--stone);
  font-size: 0.8rem;
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(40px, 8vh, 90px) clamp(16px, 4vw, 48px) 24px;
  max-width: 820px;
}

.eyebrow { color: var(--red); margin: 0 0 14px; }

.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 1.05;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
}

.lede { color: var(--stone); max-width: 54ch; margin: 0 0 32px; }

#search-form { display: flex; gap: 0; max-width: 540px; border-bottom: 1px solid var(--ink); }

#search-input {
  flex: 1;
  font: inherit;
  border: none;
  padding: 10px 2px;
  background: none;
  color: inherit;
}
#search-input:focus-visible { outline: none; }
#search-form:focus-within { border-bottom-color: var(--red); }

#search-form button {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 8px;
}
#search-form button:hover { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.chip {
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--stone);
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--red); color: var(--ink); }

.status { padding: 8px clamp(16px, 4vw, 48px); color: var(--stone); min-height: 1.5em; margin: 0; }

#sentinel { height: 1px; }

/* ---------- artwork grid (gallery wall) ----------
   Uniform matted frames with a fixed aspect ratio: space is reserved
   before images arrive, so nothing reflows or flickers while loading. */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 36px 28px;
  padding: 12px clamp(16px, 4vw, 48px) 0;
}

.work {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  text-align: left;
}

.frame {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 5;
  padding: 14px;
  background: var(--mat);
  border: 1px solid var(--hairline);
  box-shadow: 0 1px 2px rgba(27, 27, 22, 0.07);
  transition: box-shadow 0.2s, transform 0.2s;
}

.frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.frame.loading img { opacity: 0; }
.frame.loading {
  background: linear-gradient(100deg, var(--mat) 40%, #f2f0e9 50%, var(--mat) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.work:hover .frame { box-shadow: 0 10px 26px rgba(27, 27, 22, 0.16); transform: translateY(-2px); }

.work-caption { display: block; margin-top: 10px; padding: 0 2px; }
.work-caption cite { display: block; font-family: var(--serif-text); font-style: italic; font-size: 0.9rem; line-height: 1.35; }
.work-caption > span { display: block; color: var(--stone); font-size: 0.8rem; }
.work-caption .work-source { margin-top: 3px; color: var(--stone); }
.work:hover .work-caption cite { color: var(--red); }

/* ---------- dialogs ---------- */

dialog {
  border: none;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  width: min(760px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(27, 27, 22, 0.35);
}
dialog::backdrop { background: rgba(27, 27, 22, 0.55); }

.dialog-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--stone);
  z-index: 1;
}
.dialog-close:hover { color: var(--red); }

/* compose = the back of a postcard */

.postcard {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0;
  background: var(--mat);
}

.postcard-left, .postcard-right { padding: clamp(20px, 4vw, 36px); display: flex; flex-direction: column; }
.postcard-right { border-left: 1px solid var(--hairline); }

.field-label { color: var(--stone); margin: 18px 0 6px; }
.postcard-left .field-label:first-child, .postcard-right .field-label { margin-top: 18px; }

.postcard input, .postcard textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 6px 0;
}
.postcard textarea { font-family: var(--serif-text); resize: vertical; line-height: 1.6; }
.postcard input:focus-visible, .postcard textarea:focus-visible { outline: none; border-bottom-color: var(--red); }

.stamp {
  margin: 0 0 4px auto;
  padding: 5px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  width: 104px;
}
.stamp img { display: block; width: 100%; }

.compose-caption { font-size: 0.8rem; color: var(--stone); margin: 6px 0 0; }

.send {
  margin-top: 26px;
  background: var(--red);
  color: var(--mat);
  padding: 12px 22px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 600;
  align-self: flex-start;
  transition: background 0.15s;
}
.send:hover { background: #a52a18; }
.send:disabled { background: var(--stone); cursor: wait; }

.form-error { color: var(--red); font-size: 0.85rem; min-height: 1.2em; margin: 10px 0 0; }

.compose-done, .login-panel { padding: clamp(24px, 5vw, 44px); }
.compose-done h2, .login-panel h2 { font-family: var(--serif); font-weight: 400; margin: 0 0 10px; font-size: 1.7rem; }
.done-link-row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; word-break: break-all; }
#copy-link { text-decoration: underline; text-underline-offset: 3px; }
#copy-link:hover { color: var(--red); }

.login-panel p { color: var(--stone); }
.login-panel form { display: flex; flex-direction: column; }
.login-panel input {
  font: inherit;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 6px 0;
  background: none;
}
.login-panel input:focus-visible { outline: none; border-bottom-color: var(--red); }
/* reserve the widget's height so the button never jumps when it appears */
#ts-widget { margin-top: 18px; min-height: 65px; }
#login-done { color: var(--ink); }

/* ---------- card page: the gallery wall ---------- */

.card-view {
  min-height: 100svh;
  background: var(--wall);
  color: var(--wall-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(28px, 6vh, 72px) 20px 28px;
}

.card-art { margin: 0; max-width: min(680px, 94vw); text-align: center; }

.card-art img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 60svh;
  width: auto;
  padding: clamp(14px, 3vw, 30px);
  background: var(--mat);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  animation: lights 1.8s ease-out both;
}

.card-art figcaption {
  margin-top: 26px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: rgba(242, 239, 228, 0.75);
  animation: fadeup 0.8s ease-out 1.5s both;
}
.card-art figcaption cite { display: block; font-family: var(--serif-text); font-style: italic; font-size: 1rem; letter-spacing: 0; color: var(--wall-text); }
.card-art figcaption span { display: block; margin-top: 2px; }
.card-art figcaption a { display: inline-block; margin-top: 4px; color: rgba(242, 239, 228, 0.6); }

.card-message {
  max-width: 560px;
  text-align: center;
  margin-top: clamp(28px, 5vh, 52px);
  animation: fadeup 0.9s ease-out 2s both;
}

.card-text {
  font-family: var(--serif-text);
  font-style: italic;
  font-size: clamp(1.2rem, 2.6vw, 1.5rem);
  line-height: 1.65;
  margin: 0;
}

.card-from {
  margin: 18px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: rgba(242, 239, 228, 0.8);
}

.card-footer {
  margin-top: auto;
  padding-top: 48px;
  display: flex;
  gap: 14px;
  align-items: baseline;
  font-size: 0.8rem;
  color: rgba(242, 239, 228, 0.6);
  animation: fadeup 0.9s ease-out 2.4s both;
}
.card-footer .wordmark { color: var(--wall-text); }
.card-footer a { text-decoration-color: rgba(242, 239, 228, 0.35); }

@keyframes lights {
  from { opacity: 0; filter: brightness(0.2); }
  to { opacity: 1; filter: brightness(1); }
}
@keyframes fadeup {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- history ---------- */

.history { max-width: 860px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 48px); }
.history h1 { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; margin: 0 0 28px; }

.history-list { list-style: none; margin: 0; padding: 0; }

.history-item {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
}

.history-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  padding: 4px;
  background: var(--mat);
  border: 1px solid var(--hairline);
  display: block;
}

.history-meta { flex: 1; min-width: 0; }
.history-meta strong { display: block; font-weight: 500; }
.history-meta span { display: block; color: var(--stone); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-status { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.badge { color: var(--stone); }
.badge-bounced, .badge-complained, .badge-failed { color: var(--red); }
/* the gallery red dot: this one's been seen */
.badge-opened::before { content: '● '; color: var(--red); }
.badge-unopened::before { content: '○ '; }

.empty { color: var(--stone); }

/* ---------- notice pages ---------- */

.notice { max-width: 560px; margin: 0 auto; padding: 14vh 24px; text-align: center; }
.notice h1 { font-family: var(--serif); font-weight: 400; font-size: 2rem; }
.notice p { color: var(--stone); }

/* ---------- small screens / motion ---------- */

@media (max-width: 640px) {
  .postcard { grid-template-columns: 1fr; }
  .postcard-right { border-left: none; border-top: 1px solid var(--hairline); }
  .site-header nav .me { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
