.projects-main { margin: 0; padding: 64px 0 80px; }
.projects-main [hidden] { display: none !important; }
.projects-heading { max-width: 52rem; padding-bottom: 28px; }
.portfolio .projects-heading h1 { font-size: clamp(3rem, 6vw, 5rem); font-weight: 450; line-height: 1.1; letter-spacing: -.025em; margin: 0 0 24px; }
.projects-heading > p { max-width: 52ch; font-size: 1.125rem; line-height: 1.7; color: var(--ink-soft); margin: 0; }

.projects-tools { display: grid; gap: 12px; padding: 0 0 8px; }
.project-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; }
.projects-main button { font: inherit; color: var(--ink-soft); border: 0; background: transparent; min-height: 44px; cursor: pointer; padding: 8px 0; }
.project-search { display: none; }

/* Groups */
.project-group { padding-top: 40px; }
.project-group:not(:has(.project-entry:not([hidden]))) { display: none; }
.portfolio .project-group-title { margin: 0 0 4px; font-family: var(--hand); font-size: 1.35rem; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }

/* Shared image frame: a sheet with a drawn double outline */
.project-frame {
  position: relative; isolation: isolate; display: block; aspect-ratio: 16 / 10;
  background: var(--paper-2); overflow: visible;
}
.project-frame img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; border-radius: 6px 3px 7px 4px; }
.project-frame.is-contain { background: var(--paper); }
.project-frame.is-contain img { object-fit: contain; object-position: center; padding: 6%; }
.project-frame::before, .project-frame::after { content: ""; position: absolute; pointer-events: none; z-index: 1; }
.project-frame::before { inset: -1px; border: 1.6px solid var(--stroke); border-radius: 9px 3px 10px 4px / 4px 10px 3px 9px; }
.project-frame::after { inset: 2px -4px -3px 3px; z-index: -1; border: 1.1px solid var(--stroke-soft); border-radius: 4px 10px 3px 9px / 9px 3px 10px 4px; transform: rotate(-.7deg); }
.project-frame:hover::before { border-color: var(--accent); }

/* Meta and links */
.project-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 10px; color: var(--ink-soft); font-size: .8125rem; }
.project-entry h3 { margin: 0; font-weight: 500; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.project-entry h3 a { color: var(--ink); text-decoration: none; }
.project-entry h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1.5px; }
.project-deck { margin: 10px 0 0; color: var(--ink); line-height: 1.55; }
.project-detail { margin: 10px 0 0; color: var(--ink-soft); line-height: 1.65; max-width: 52ch; }
.project-entry-links { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 18px; }
.project-entry-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); }

/* Main projects: image and copy side by side, alternating sides */
.project-feature { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px clamp(32px, 5vw, 72px); align-items: center; padding: 40px 0; border-bottom: 1px solid var(--rule); scroll-margin-top: 24px; }
.project-feature:last-child { border-bottom: 0; }
.project-feature:nth-of-type(even) .project-frame { order: 2; }
.portfolio .project-feature h3 { font-size: clamp(1.6rem, 2.4vw, 2.3rem); }
.project-feature .project-deck { font-size: 1.0625rem; max-width: 46ch; }

/* Experiments: a loose grid of pinned sketches */
.project-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 40px; padding-top: 24px; }
.project-tile { scroll-margin-top: 24px; }
.project-tile .project-frame { aspect-ratio: 4 / 3; margin-bottom: 18px; transform: rotate(-.5deg); }
.project-tile:nth-child(3n + 2) .project-frame { transform: rotate(.6deg); }
.project-tile:nth-child(3n) .project-frame { transform: rotate(-.2deg); }
.portfolio .project-tile h3 { font-size: 1.25rem; }
.project-tile .project-deck { margin-top: 6px; font-size: .9375rem; color: var(--ink-soft); }

.projects-empty { border-top: 1px solid var(--rule); padding: 48px 0; }
.projects-empty p { margin: 0 0 12px; }

.project-dialog { width: min(94vw, 1200px); max-height: 92vh; padding: 20px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); }
.project-dialog::backdrop { background: rgba(35, 33, 28, .72); }
.project-dialog figure { margin: 12px 0 0; }
.project-dialog img { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.project-dialog figcaption { margin-top: 16px; font-size: .875rem; }
.preview-close { display: block; margin-left: auto; }
.project-dialog .preview-motion { float: left; color: var(--accent); text-decoration: underline; }

@media (max-width: 1000px) {
  .project-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .project-feature { grid-template-columns: 1fr; gap: 22px; padding: 32px 0; }
  .project-feature:nth-of-type(even) .project-frame { order: 0; }
}
@media (max-width: 560px) {
  .projects-main { padding-top: 40px; }
  .project-tiles { grid-template-columns: 1fr; gap: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .project-tile .project-frame { transform: none; }
}
