*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 17px; }

body {
  background: #fff;
  color: #222;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  line-height: 1.65;
}

a {
  color: #222;
  text-decoration: underline;
}

a:hover { color: #555; }

/* ── Header ── */

header {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid #ddd;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
}

.site-name {
  font-size: 1.35rem;
  font-weight: bold;
  text-decoration: none;
  color: #222;
  white-space: nowrap;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  align-items: baseline;
}

nav a {
  font-size: 0.95rem;
  text-decoration: none;
  color: #555;
}

nav a:hover,
nav a.active { color: #222; }

/* ── Main ── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  animation: fadeIn 0.35s ease both;
}

/* ── About page layout ── */

.about-page {
  padding-top: 1.5rem;
}

.about-top {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
  align-items: start;
}

.about-photo {
  grid-column: 2;
  grid-row: 1;
  padding-top: 18px;
}

.about-bio {
  grid-column: 1;
  grid-row: 1;
}

.about-photo img {
  width: 100%;
  height: 340px;
  object-fit: cover;
  display: block;
}

.about-footer {
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid #eee;
}

.quotes-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem;
  margin-bottom: 1.5rem;
}

.contact-quote {
  font-style: italic;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.7;
}

@media (max-width: 680px) {
  .quotes-row {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

.contact-email {
  font-size: 0.9rem;
  color: #555;
}

.prose h1 {
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 1.25rem;
}

.prose h2 {
  font-size: 1.15rem;
  font-weight: bold;
  margin: 2rem 0 0.75rem;
}

.prose h3 {
  font-size: 1rem;
  font-weight: bold;
  margin: 1.5rem 0 0.5rem;
}

.prose p { margin-bottom: 1rem; }

.prose ul, .prose ol {
  margin: 0 0 1rem 2rem;
  padding: 0;
}

.prose li { margin-bottom: 0.25rem; }

.prose blockquote {
  margin: 1.25rem 0;
  padding-left: 1.25rem;
  border-left: 3px solid #ddd;
  color: #555;
}

.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}

/* ── Essays sidebar ── */

.essays-sidebar h2 {
  font-size: 1rem;
  font-weight: bold;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #ddd;
}

.essays-sidebar h2:first-child {
  margin-top: 0;
}

.essays-sidebar ul {
  list-style: none;
}

.essays-sidebar li {
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
}

.essays-sidebar li:last-child { border-bottom: none; }

.essays-sidebar .essay-title a {
  font-size: 0.95rem;
  text-decoration: none;
  color: #222;
}

.essays-sidebar .essay-title a:hover { text-decoration: underline; }

.essays-sidebar .essay-date {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.1rem;
}

/* ── Essays list page ── */

.essays-list h1 {
  font-size: 1.4rem;
  font-weight: bold;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #ddd;
}

.essay-entry {
  padding: 1rem 0;
  border-bottom: 1px solid #eee;
}

.essay-entry:last-child { border-bottom: none; }

.research-heading {
  margin-top: 4rem;
}

/* ── Feedback form ── */

.feedback-page h1 {
  font-size: 1.6rem;
  font-weight: bold;
  margin-bottom: 0.75rem;
}

.feedback-page > p {
  color: #555;
  margin-bottom: 2rem;
}

.feedback-form {
  max-width: 560px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.9rem;
  color: #333;
}

.form-optional {
  color: #aaa;
  font-size: 0.8rem;
}

.form-group input,
.form-group textarea {
  font-family: inherit;
  font-size: 1rem;
  color: #222;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: #999;
}

.form-group textarea {
  resize: vertical;
  line-height: 1.6;
}

.form-submit {
  font-family: inherit;
  font-size: 0.95rem;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 0.6rem 1.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.form-submit:hover {
  background: #444;
}

/* ── Post cards ── */

.post-cards {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.post-card {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}

.post-card:hover {
  border-color: #bbb;
}

.post-card-image {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}

.research-card .post-card-image {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.research-card .post-card-image img {
  width: 50%;
  height: 50%;
  object-fit: contain;
  border-radius: 0;
  filter: saturate(0.6) brightness(0.82);
}

.post-card-body {
  flex: 1;
  min-width: 0;
}

.post-card-title {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.post-card-date {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.4rem;
}

.post-card-desc {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.5;
}

.essay-entry .title {
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.essay-entry .title a { text-decoration: none; }
.essay-entry .title a:hover { text-decoration: underline; }

.essay-entry .date {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.35rem;
}

.essay-entry .summary {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.5;
}

/* ── Single essay page ── */

figure.universe-img {
  text-align: center;
  margin: 0.75rem 0;
}

figure.universe-img img {
  max-width: 240px;
  width: 100%;
  display: inline-block;
}

.essay-header { margin-bottom: 2rem; }

/* ── Sidenotes ── */

.prose {
  position: relative;
  overflow: visible;
}

.sidenote-ref {
  font-size: 0.7rem;
  vertical-align: super;
  color: #aaa;
  line-height: 0;
  margin-left: 1px;
  font-style: normal;
}

.sidenote {
  position: absolute;
  right: -300px;
  width: 240px;
  font-size: 0.78rem;
  color: #888;
  line-height: 1.6;
}

.sidenote-number {
  display: block;
  font-size: 0.7rem;
  color: #bbb;
  margin-bottom: 0.15rem;
}

.sidenote-body p { margin: 0; }
.sidenote-body a { color: #888; }

/* Edit mode: highlight sidenotes inline */
.prose[contenteditable="true"] .sidenote {
  position: static;
  display: inline-block;
  background: #fffbe6;
  border: 1px dashed #e0c96e;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-size: 0.85rem;
  color: #888;
  cursor: text;
  vertical-align: baseline;
  width: auto;
}

.prose[contenteditable="true"] .sidenote-number {
  display: none;
}

/* Narrow screens: hide inline, show as footnotes at bottom via JS */
@media (max-width: 1100px) {
  .sidenote {
    display: none;
  }

  .footnotes-section {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
  }

  .footnotes-section ol {
    padding-left: 1.5rem;
    font-size: 0.82rem;
    color: #888;
    line-height: 1.6;
  }

  .footnotes-section li {
    margin-bottom: 0.5rem;
  }

  .footnotes-section a { color: #aaa; }
}

.essay-header h1 {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.essay-header .date {
  font-size: 0.85rem;
  color: #888;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
  color: #555;
}

.back-link:hover { color: #222; }

/* ── See more button ── */

.see-more-btn {
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
  text-decoration: underline;
}

.see-more-btn:hover { color: #444; }

/* ── Footer ── */

footer {
  border-top: 1px solid #ddd;
  padding: 1.25rem 2rem;
  font-size: 0.85rem;
  color: #888;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
}

footer a {
  color: #888;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ── Responsive ── */

/* Tablet: float photo right, text wraps */
@media (min-width: 500px) and (max-width: 799px) {
  .about-top {
    display: block;
    overflow: hidden;
  }

  .about-photo {
    float: right;
    width: 220px;
    margin: 0 0 1rem 2rem;
  }

  .about-photo img {
    width: 220px;
    height: 260px;
    object-fit: cover;
    object-position: center top;
  }
}

/* ── Localhost link popover ── */

#link-popover {
  position: absolute;
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0.4rem 0.6rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 10000;
}

#link-icon { font-size: 0.8rem; }

#link-input {
  font-family: inherit;
  font-size: 0.85rem;
  border: none;
  outline: none;
  width: 260px;
  color: #222;
}

#link-popover button {
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #555;
  padding: 0 0.2rem;
}

#link-popover button:hover { color: #222; }

/* ── Localhost edit bar ── */

#edit-bar {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #222;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  z-index: 9999;
}

#edit-bar button {
  font-family: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
}

#edit-bar button:hover { color: #ccc; }

#edit-msg {
  font-size: 0.8rem;
  color: #aaa;
}

.prose[contenteditable="true"] {
  outline: none;
  border-left: 2px solid #ddd;
  padding-left: 1rem;
}

/* Phone: hide photo */
@media (max-width: 499px) {
  .about-top { display: block; }
  .about-photo { display: none; }
  nav { gap: 0.25rem 1rem; }
}

@media (max-width: 680px) {
  .quotes-row { grid-template-columns: 1fr; gap: 1.25rem; }
  nav { gap: 0.25rem 1rem; }
}
