/* Bento personal site styles */

:root {
  color-scheme: light dark;
  --bg: #e9e9e7;
  --surface: #ffffff;
  --surface-inverse: #1d2025;
  --text: #1a1a1a;
  --text-muted: #5a5a5a;
  --border: #e2e0da;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --accent: #2f6fed;
  --radius: 14px;
  --gap: 1rem;
  --font-heading: "owners", sans-serif;
  --font-body: "basic-sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1d2025;
    --surface-inverse: #ffffff;
    --text: #f2f1ee;
    --text-muted: #a8a8a8;
    --border: #2c2f36;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --accent: #6d9dff;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1d2025;
  --surface-inverse: #ffffff;
  --text: #f2f1ee;
  --text-muted: #a8a8a8;
  --border: #2c2f36;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --accent: #6d9dff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  font-style: normal;
  padding: clamp(1rem, 4vw, 2.5rem);
}

h1,
h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.05em;
}

a {
  font-family: var(--font-heading);
  font-weight: 500;
  font-style: normal;
}

.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(180px, auto);
  grid-auto-flow: dense;
  gap: var(--gap);
  max-width: 1600px;
  margin: 0 auto;
}

.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  overflow-wrap: break-word;
  animation: box-in 0.5s ease-out both;
  animation-delay: calc(sibling-index() * 50ms);
}

@keyframes box-in {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .box {
    animation: none;
  }
}

.box[hidden] {
  display: none;
}

.box--about {
  position: relative;
  grid-column: span 2;
  grid-row: span 2;
  padding: 0;
  overflow: hidden;
  flex-direction: row;
}

.about-photo {
  width: 40%;
  height: 100%;
  flex-shrink: 0;
  object-fit: cover;
}

.about-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

.box--family {
  grid-column: span 2;
}

.box[data-name="sparrow-sleeps"] {
  grid-column: span 2;
}

.box[data-name="illustration"] {
  grid-column: span 2;
  grid-row: span 2;
}

.box[data-name="woodworking"] {
  grid-row: span 2;
}

@media (max-width: 899px) {
  .bento {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 599px) {
  .bento {
    grid-template-columns: 1fr;
  }

  .box,
  .box--about,
  .box--family,
  .box[data-name="sparrow-sleeps"],
  .box[data-name="illustration"],
  .box[data-name="woodworking"] {
    grid-column: span 1;
    grid-row: span 1;
  }

  .box--about {
    flex-direction: column;
  }

  .about-photo {
    order: 2;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
  }

  .about-content {
    order: 1;
    justify-content: flex-start;
  }
}

.box h1 {
  margin: 0;
  font-size: 1.6rem;
}

.box h2 {
  margin: 0;
  font-size: 1.05rem;
}

.box p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.social-icons {
  container-type: inline-size;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.75rem, 4cqw, 2rem);
  align-items: center;
  justify-content: flex-start;
  margin-top: 10px;
}

.social-icons a {
  color: var(--text);
  display: inline-flex;
}

.social-icons a:hover {
  color: var(--accent);
}

.social-icons svg {
  width: clamp(24px, 9cqw, 30px);
  height: clamp(24px, 9cqw, 30px);
  flex-shrink: 0;
}

.box-link {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  text-decoration: none;
  margin-top: auto;
  letter-spacing: 0.1em;
  font-size: 14px;
}

.box-link-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke-width: 2.75;
  transition: transform 0.2s ease;
}

.box-link:hover .box-link-arrow {
  transform: translateX(5px);
}

.box--carousel {
  padding: 0;
  overflow: hidden;
}

.carousel {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-slides {
  position: absolute;
  inset: 0;
}

.carousel-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.carousel-slide.is-active {
  opacity: 1;
  z-index: 1;
}

.carousel.is-lightbox-active {
  visibility: hidden;
}

.carousel.is-lightbox-active .carousel-caption,
.carousel.is-lightbox-active .carousel-dots {
  /* Overrides the inherited hidden state so their own opacity fade (driven by
     script.js) can still render while the image stays fully hidden. */
  visibility: visible;
}

.box--carousel:has(.carousel.is-lightbox-active) {
  background: var(--surface-inverse);
}

.carousel-caption {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  padding: 3rem .8rem 1.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
}

.carousel-caption h2 {
  color: #fff;
  margin: 0;
}

/* Instagram Stories-style progress bar: one thin segment per slide,
   spanning the full width of the box rather than a row of small dots. */
.carousel-dots {
  position: absolute;
  bottom: 0.7rem;
  left: 0.7rem;
  right: 0.7rem;
  z-index: 3;
  display: flex;
  gap: 0.3rem;
}

.carousel-dot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 3px;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.carousel-dot::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.carousel-dot.is-active {
  background: #fff;
}

.carousel-dot:not(.is-active):hover {
  background: rgba(255, 255, 255, 0.7);
}

.carousel-trigger {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  /* The native pointer is replaced by .carousel-cursor below, which fades
     and scales in/out instead of snapping in like a real cursor would. */
  cursor: none;
}

/* Custom "expand to fullscreen" cursor: a white circle with a maximize icon
   that follows the pointer anywhere over the box, fading/scaling in and out
   on hover. Position (left/top) is set on the fly in script.js; only the
   hover-driven opacity/scale transition lives here. `fixed` (and living on
   <body>, per script.js) keeps it from being clipped by the box's own
   `overflow: hidden`, which crops the carousel photo to the box's shape. */
.carousel-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 500;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cpolyline points='9 21 3 21 3 15'/%3E%3Cline x1='21' y1='3' x2='14' y2='10'/%3E%3Cline x1='3' y1='21' x2='10' y2='14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 1.5rem;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.carousel-cursor.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.lightbox.is-visible {
  pointer-events: auto;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg);
  opacity: 0;
}

.lightbox.is-visible .lightbox-backdrop {
  opacity: 1;
}

.lightbox[hidden] {
  display: none;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-header {
  flex: 0 0 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
}

.lightbox-title {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.lightbox-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  color: color-mix(in srgb, var(--text) 70%, transparent);
}

.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  container-type: size;
}

.lightbox-slides {
  position: absolute;
  inset: 0;
}

.lightbox-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* cover (not contain) so that while the FLIP animation resizes this box
     between the small carousel's shape and the fullscreen content rect, the
     crop continuously interpolates too — starting identical to the box's
     own object-fit: cover crop and smoothly uncropping as it grows. At rest
     the box is sized (via computeContentRect) to exactly match the photo's
     aspect ratio, so cover and contain render identically there. */
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
  /* Rounded unless this photo's aspect ratio makes it span the stage's full
     width (touching the left/right edges) — then flush corners read better
     against the viewport edge. `--ratio` (naturalWidth/naturalHeight) is set
     per slide in script.js. The (…)*1e5 saturates the clamp to exactly 0 or
     --radius — there's no meaningful in-between value. */
  border-radius: clamp(0px, (100cqi - 100cqb * var(--ratio, 1)) * 1e5, var(--radius));
}

.lightbox-slide.is-active {
  opacity: 1;
  z-index: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  color: var(--text);
  cursor: pointer;
  transform: translateY(-50%);
}

.lightbox-nav:hover {
  background: color-mix(in srgb, var(--text) 24%, transparent);
}

.lightbox-nav svg {
  width: 24px;
  height: 24px;
}

.lightbox-nav--prev {
  left: 1rem;
}

.lightbox-nav--next {
  right: 1rem;
}

.lightbox-nav[hidden] {
  display: none;
}

.lightbox-thumbs {
  flex: 0 0 90px;
  height: 90px;
}

.lightbox-thumbs-track {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  margin: 0;
  padding: 0 1rem;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.lightbox-thumb {
  flex: none;
  scroll-snap-align: center;
}

.lightbox-thumb button {
  display: block;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  opacity: 0.55;
  cursor: pointer;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  transition: opacity 220ms ease, box-shadow 220ms ease;
}

.lightbox-thumb button:hover,
.lightbox-thumb button:focus-visible {
  opacity: 1;
}

.lightbox-thumb button[aria-current="true"] {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent);
}

.lightbox-thumb img {
  display: block;
  height: 100%;
  width: auto;
  object-fit: cover;
}

:where(.carousel-trigger, .carousel-dot, .lightbox-close, .lightbox-thumb button, .lightbox-nav, .theme-toggle):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle-icon {
  width: 18px;
  height: 18px;
}

.theme-toggle-icon--sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-icon--sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-toggle-icon--moon {
    display: none;
  }
}

:root[data-theme="dark"] .theme-toggle-icon--sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle-icon--moon {
  display: none;
}

.box[data-name="foxio"] {
  background: #ea2c28;
  border-color: transparent;
}

.box[data-name="foxio"] h2,
.box[data-name="foxio"] p,
.box[data-name="foxio"] .box-link {
  color: #fff;
}

.box[data-name="foxio"] p {
  opacity: 0.8;
}

.box[data-name="sparrow-sleeps"] {
  background: #4fbc83;
  border-color: transparent;
}

.box[data-name="sparrow-sleeps"] h2,
.box[data-name="sparrow-sleeps"] p,
.box[data-name="sparrow-sleeps"] .box-link {
  color: #fff;
}

.box[data-name="sparrow-sleeps"] p {
  opacity: 0.8;
}

.box[data-name="hen-dog-is-forever"] {
  background: #28448e;
  border-color: transparent;
}

.box[data-name="hen-dog-is-forever"] h2,
.box[data-name="hen-dog-is-forever"] p,
.box[data-name="hen-dog-is-forever"] .box-link {
  color: #fff;
}

.box[data-name="hen-dog-is-forever"] p {
  opacity: 0.8;
}

.box[data-name="icons-have-feelings-too"] {
  background: #ffffff;
  border-color: transparent;
}

.box[data-name="icons-have-feelings-too"] h2,
.box[data-name="icons-have-feelings-too"] p,
.box[data-name="icons-have-feelings-too"] .box-link {
  color: #000000;
}

.box[data-name="icons-have-feelings-too"] p {
  opacity: 0.8;
}

.site-footer {
  max-width: 1600px;
  margin: 1.5rem auto 0;
  padding: 0 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}
