/* =============================================================================
   Loukoum — site-wide styles
   ============================================================================= */

html {
  scroll-behavior: smooth;
  overflow-x: hidden; /* prevent horizontal scroll without breaking sticky */
}
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-loose);
  margin: 0;
  overflow-x: hidden;
}

/* ===== Layout shell ===== */
.app {
  display: grid;
  grid-template-columns: 480px 1fr;
  min-height: 100vh;
  /* Paint the sidebar column background the full page height */
  background: linear-gradient(
    to right,
    var(--paper) 480px,
    var(--rule)  480px,
    var(--rule)  481px,
    var(--cream) 481px
  );
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: var(--paper);
  padding: 64px 32px 32px 96px;
  display: flex;
  flex-direction: column;
  gap: 48px;
  border-right: 1px solid var(--rule);
}

.lockup {
  display: block;
  text-decoration: none;
  color: inherit;
}
.lockup .name {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.008em;
  line-height: var(--lh-snug);
  display: block;
  white-space: nowrap;
  transition: letter-spacing 400ms var(--ease-out);
}
.lockup:hover .name {
  letter-spacing: 0.024em;
}

/* nav */
.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sb-link {
  position: relative;
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--slate);
  text-decoration: none;
  padding: 4px 0;
  transition: color var(--dur-instant) var(--ease-out);
}
.sb-link::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 50%;
  width: 0;
  height: 2px;
  background: var(--etruscan);
  opacity: 0.35;
  transform: translateY(-50%);
  transition: width var(--dur-default) var(--ease-out),
              opacity var(--dur-default) var(--ease-out);
}
.sb-link:hover { color: var(--ink); }
.sb-link:hover::before { width: 10px; }
.sb-link[aria-current="page"] { color: var(--ink); }
.sb-link[aria-current="page"]::before { width: 16px; opacity: 1; }

/* footer */
.sb-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--stone);
}
.sb-email {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-instant) var(--ease-out);
}
.sb-email:hover { color: var(--ink); }

.sb-social {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sb-social a {
  color: var(--stone);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dur-instant) var(--ease-out);
}
.sb-social a:hover { color: var(--ink); }
.sb-social svg { width: 16px; height: 16px; display: block; }

/* ===== Main column ===== */
.main {
  padding: 64px 96px 128px 96px;
  min-width: 0; /* allow grid cell to shrink */
  overflow-wrap: break-word;
}
.article {
  max-width: none;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.008em;
  line-height: var(--lh-snug);
  margin: 0 0 32px 0;
}

.article p {
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-loose);
  color: var(--ink);
  max-width: none;
  text-wrap: pretty;
  margin: 0 0 20px 0;
}
.article p:last-child { margin-bottom: 0; }

.article a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-mid);
  text-underline-offset: 3px;
  transition: text-decoration-thickness var(--dur-instant) var(--ease-out),
              text-decoration-color var(--dur-instant) var(--ease-out),
              color var(--dur-instant) var(--ease-out);
}
.article a:hover {
  color: var(--etruscan);
  text-decoration-thickness: 2px;
  text-decoration-color: var(--rule-accent);
}

.article em, .article i { font-style: italic; }
.article strong { font-weight: 500; }

/* ===== About — portrait (sketched frame, hover/tap easter egg) ===== */
.article::after { content: ""; display: table; clear: both; }

.pf { float: left; width: 184px; margin: 6px 34px 16px 0; }
.pf + .section-heading { margin-bottom: 16px; }
.pf-box { position: relative; width: 184px; height: 184px; }
.pf-photo {
  position: absolute; inset: 13px; overflow: hidden;
  background: var(--bone); cursor: pointer;
}
.pf-photo img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  filter: saturate(1.06) contrast(1.02) brightness(1.03) sepia(0.05);
}
.pf-front { object-position: 44% 28%; transform: scale(1.16); transition: opacity .32s var(--ease-out); z-index: 2; }
.pf-back  { object-position: 47% 40%; transform: scale(1.08); z-index: 1; }
.pf-frame { position: absolute; inset: 0; width: 184px; height: 184px; z-index: 4; pointer-events: none; }
.pf:hover .pf-front, .pf.is-swapped .pf-front { opacity: 0; }

.pf-cap { position: relative; height: 30px; margin: 12px 0 0 13px; }
.pf-word {
  position: absolute; left: 2px; top: 0;
  font-family: var(--font-hand); color: var(--etruscan);
  font-size: 22px; line-height: 1; white-space: nowrap;
  transform: rotate(-4deg); transition: opacity .32s var(--ease-out);
}
.pf-word.is-back { opacity: 0; }
.pf:hover .pf-word.is-front, .pf.is-swapped .pf-word.is-front { opacity: 0; }
.pf:hover .pf-word.is-back, .pf.is-swapped .pf-word.is-back { opacity: 1; }

/* ===== Project row (Building page) ===== */
.project-row {
  padding: 8px 0 0 0;
  margin-top: 4px;
  max-width: var(--measure);
}
.project-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 18px;
}
.project-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
}
.project-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}
.project-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15.5px;
  font-weight: 400;
  color: var(--slate);
  flex: 1 1 280px;
  min-width: 0;
}
.project-status {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--etruscan);
  white-space: nowrap;
}
.project-body {
  padding-left: var(--space-5);
}
.project-body p { margin-bottom: 16px; }
.project-body p:last-child { margin-bottom: 0; }

.project-cta a {
  border-bottom: 1px solid var(--rule-mid);
  text-decoration: none;
  padding-bottom: 1px;
  transition: border-color var(--dur-instant) var(--ease-out),
              color var(--dur-instant) var(--ease-out);
}
.project-cta a:hover {
  color: var(--etruscan);
  border-bottom-color: var(--rule-accent);
  border-bottom-width: 2px;
  padding-bottom: 0;
}

/* ===== Work with me list ===== */
.wwm-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.wwm-list li {
  padding-left: var(--space-5);
  border-left: 2px solid var(--rule-accent);
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-loose);
  color: var(--ink);
}

/* ===== Writing index ===== */
.writing-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
}
.writing-list li {
  border-bottom: 1px solid var(--rule);
}
.writing-entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  padding: 24px 0;
  text-decoration: none;
  color: inherit;
  transition: color var(--dur-instant) var(--ease-out);
}
.writing-entry:hover { color: var(--etruscan); }
.writing-entry .w-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--etruscan) !important;
  padding-top: 6px;
  white-space: nowrap;
}
.writing-entry .w-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}
.writing-entry:hover .w-title { color: var(--etruscan); }
/* Override .article a underline */
.article .writing-entry,
.article .writing-entry:hover {
  text-decoration: none;
}

.writing-empty {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-body);
  color: var(--slate);
  max-width: var(--measure);
  margin: 24px 0 0 0;
}

/* ===== Building — project list ===== */
.project-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
}
.project-list > li {
  border-bottom: 1px solid var(--rule);
}
.project-entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  padding: 24px 0;
}
.project-entry .p-status {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--etruscan);
  padding-top: 6px;
  white-space: nowrap;
}
.project-entry .p-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  margin: 0 0 10px 0;
}
.project-entry p {
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-loose);
  color: var(--ink);
  margin: 0 0 14px 0;
  max-width: 100%;
  text-wrap: pretty;
}
.project-entry p:last-child { margin-bottom: 0; }
.project-entry .project-cta a {
  border-bottom: 1px solid var(--rule-mid);
  text-decoration: none;
  padding-bottom: 1px;
  color: inherit;
  transition: border-color var(--dur-instant) var(--ease-out),
              color var(--dur-instant) var(--ease-out);
}
.project-entry .project-cta a:hover {
  color: var(--etruscan);
  border-bottom-color: var(--rule-accent);
  border-bottom-width: 2px;
  padding-bottom: 0;
}

/* Arrow nudge on CTA hover */
.project-cta a .arrow {
  display: inline-block;
  transition: transform var(--dur-default) var(--ease-out);
}
.project-cta a:hover .arrow {
  transform: translateX(3px);
}

/* Status dot pulse */
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.85); }
}
.p-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--etruscan);
  animation: dot-pulse 4s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ===== Essay (writing/*) ===== */
.essay { max-width: none; }
.essay-back {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--stone);
  text-decoration: none;
  margin-bottom: var(--space-7);
  transition: color var(--dur-instant) var(--ease-out);
}
.essay-back:hover { color: var(--ink); }

.essay-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--etruscan);
  margin: 0 0 16px 0;
}

.essay-title {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  font-weight: 500;
  color: var(--ink);
  line-height: var(--lh-snug);
  letter-spacing: -0.008em;
  margin: 0 0 var(--space-7) 0;
  text-wrap: balance;
}

.essay p {
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-loose);
  color: var(--ink);
  max-width: none;
  text-wrap: pretty;
  margin: 0 0 22px 0;
}

.essay blockquote {
  margin: 28px 0;
  padding: 4px 0 4px 24px;
  border-left: 2px solid var(--rule-accent);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17.5px;
  line-height: var(--lh-normal);
  color: var(--slate);
  max-width: none;
  text-wrap: pretty;
}
.essay blockquote p { margin: 0 0 12px 0; font-style: italic; color: var(--slate); }
.essay blockquote p:last-child { margin-bottom: 0; }
.essay blockquote cite {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: var(--fs-meta);
  letter-spacing: var(--tr-meta);
  text-transform: uppercase;
  color: var(--stone);
}

.essay em, .essay i { font-style: italic; }
.essay strong { font-weight: 500; }

/* Pencil mark — hand-drawn etruscan underline.
   Wavy SVG, gently irregular, scaled to the text. */
.pencil,
.essay .pencil {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 6' preserveAspectRatio='none'%3E%3Cpath d='M1.5 3.6 C 16 1.8, 30 4.6, 46 2.8 S 78 4.8, 94 2.6 S 112 4.6, 118.5 3.2' stroke='%23157F49' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 0.38em;
  padding-bottom: 3px;
}

.essay a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-mid);
  text-underline-offset: 3px;
  transition: text-decoration-thickness var(--dur-instant) var(--ease-out),
              text-decoration-color var(--dur-instant) var(--ease-out),
              color var(--dur-instant) var(--ease-out);
}
.essay a:hover {
  color: var(--etruscan);
  text-decoration-thickness: 2px;
  text-decoration-color: var(--rule-accent);
}

/* ===== Narrow desktop / large tablet (1100px) ===== */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 320px 1fr;
    background: linear-gradient(
      to right,
      var(--paper) 320px,
      var(--rule)  320px,
      var(--rule)  321px,
      var(--cream) 321px
    );
  }
  .sidebar {
    padding: 48px 24px 32px 48px;
  }
  .lockup .name {
    white-space: normal;
  }
  .main {
    padding: 48px 48px 96px 48px;
  }
}

/* ===== Mobile (860px and below) ===== */
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    background: none; /* no column split on mobile */
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px 24px;
    padding: 20px 24px;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .lockup .name {
    font-size: var(--fs-h3);
    white-space: nowrap;
  }
  .sb-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 16px;
  }
  .sb-link {
    font-size: var(--fs-body);
    padding: 4px 0;
  }
  .sb-link::before { display: none; }
  .sb-link[aria-current="page"] { color: var(--etruscan); }
  .sb-foot { display: none; }
  .main { padding: 32px 24px 80px 24px; }
  .article { max-width: 100%; }
  .pf { float: none; margin: 0 0 24px 0; }
  .project-status { margin-left: 0; }
  .project-tagline { flex-basis: 100%; }
  .project-entry { grid-template-columns: 1fr; gap: 8px; }
  .writing-entry { grid-template-columns: 1fr; gap: 6px; padding: 18px 0; }
  .writing-entry .w-tag { padding-top: 0; }
  .essay p { max-width: 100%; }
}

/* =============================================================================
   Easter eggs — small delights
   ============================================================================= */

/* Pencil marks draw themselves in as they enter view.
   Progressive enhancement: with no JS, .pencil keeps its full underline. */
.js .pencil {
  background-size: 0% 0.38em;
  transition: background-size var(--dur-deliberate) var(--ease-out);
}
.js .pencil.is-drawn { background-size: 100% 0.38em; }

/* The word "delight" pays out tiny hand-drawn loukoums (/building). */
.delight-egg { cursor: pointer; }
.delight-tray { white-space: nowrap; }
.loukoum { vertical-align: -3px; margin-left: 3px; }
.loukoum-pop { animation: loukoum-pop 340ms var(--ease-out); transform-origin: 50% 80%; }
@keyframes loukoum-pop {
  0%   { transform: scale(0.3) translateY(5px) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) translateY(0) rotate(0); opacity: 1; }
}
.loukoum-enough {
  font-family: var(--font-hand);
  font-size: 14px;
  color: var(--etruscan);
  margin-left: 6px;
  opacity: 0;
  transition: opacity 450ms var(--ease-out);
}
.loukoum-enough.is-shown { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .js .pencil { transition: none; }
  .loukoum-pop { animation: none; }
  .loukoum-enough { transition: none; }
}

/* =============================================================================
   Building — expandable project list
   ============================================================================= */
.bld-list { margin-top: var(--space-5); }
.bld-proj { border-top: 1px solid var(--rule); }
.bld-proj:last-of-type { border-bottom: 1px solid var(--rule); }

.bld-head {
  display: flex; align-items: baseline; gap: 14px;
  padding: 16px 0; cursor: pointer; list-style: none;
}
.bld-head::-webkit-details-marker { display: none; }
.bld-head:hover .bld-name { color: var(--etruscan); }
.bld-name { font-size: 20px; font-weight: 500; transition: color var(--dur-instant) var(--ease-out); }
.bld-story { font-style: italic; color: var(--ink); font-size: 15px; transition: color var(--dur-instant) var(--ease-out); }
.bld-proj:hover .bld-story,
.bld-proj[open] .bld-story { color: var(--etruscan); }
.bld-proj.off .bld-name { color: var(--stone); }
.bld-proj.off .bld-story { color: var(--stone); }
.bld-meta { margin-left: auto; display: inline-flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.bld-status { font-family: var(--font-hand); font-size: 15px; color: var(--etruscan); }
.bld-status.off { color: var(--stone); }
.bld-chev {
  font-family: var(--font-mono); font-size: 15px; color: var(--stone);
  display: inline-block; transition: transform var(--dur-default) var(--ease-out);
}
.bld-proj[open] .bld-chev { transform: rotate(90deg); }

.bld-panel { padding: 2px 0 26px; }
.bld-shot svg {
  display: block; width: 480px; max-width: 100%;
  border: 1px solid var(--rule); border-radius: 2px;
}
.article .bld-desc {
  font-size: 15.5px; line-height: 1.55; color: var(--slate);
  margin: 14px 0 9px; max-width: 46ch;
}
.article .bld-cta { font-family: var(--font-mono); font-size: 10px; line-height: 1.6; color: var(--ink); letter-spacing: .06em; text-transform: uppercase; }
.bld-cta a { color: var(--ink); text-decoration: none; }
.bld-cta a:hover { color: var(--etruscan); }

/* The trace draws itself in as the diagram enters view. */
.js .bld-graph .tdraw { stroke-dashoffset: var(--len, 0); stroke-dasharray: var(--len, 0); }
.js .bld-graph.is-traced .tdraw { stroke-dashoffset: 0; }

@media (max-width: 700px) {
  .bld-head { flex-wrap: wrap; gap: 4px 12px; }
  .bld-meta { margin-left: 0; }
  .bld-shot svg { width: 100%; }
}
