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

:root {
  --bg: #faf6f0;
  --bg-soft: #f5ebe0;
  --card: #ffffff;
  --text: #3d3229;
  --text-muted: #7a6b5e;
  --accent: #d4845f;
  --accent-hover: #c0724d;
  --shadow: 0 4px 24px rgba(61, 50, 41, 0.08);
  --shadow-hover: 0 8px 32px rgba(61, 50, 41, 0.14);
  --radius: 14px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 280ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

body.modal-open {
  overflow: hidden;
}

h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.site-header {
  text-align: center;
  padding: calc(2.5rem + var(--safe-top)) 1rem 2rem;
  animation: fadeUp 0.5s var(--ease) both;
}

.site-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  letter-spacing: 0.02em;
}

.site-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.section {
  margin-bottom: 3rem;
}

.section-title {
  margin: 0 0 1.25rem;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  color: var(--text);
}

.featured-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 481px) {
  .featured-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 769px) {
  .site-main {
    padding: 0 2rem 4rem;
  }
}

.work-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.45s var(--ease) forwards;
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.work-card:hover {
  box-shadow: var(--shadow-hover);
}

.work-card__image-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg-soft);
}

.work-card__image {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  transition: transform var(--duration) var(--ease);
}

.work-card:hover .work-card__image {
  transform: scale(1.02);
}

.work-card__body {
  padding: 1rem 1.1rem 1.25rem;
}

.work-card__title {
  margin: 0 0 0.35rem;
  font-family: Georgia, serif;
  font-size: 1.15rem;
}

.work-card__badge {
  position: absolute;
  bottom: 0.65rem;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-hover);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(61, 50, 41, 0.12);
  pointer-events: none;
  white-space: nowrap;
}

.btn-meaning {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: background var(--duration) var(--ease), transform 0.15s var(--ease);
}

.btn-meaning:hover {
  background: var(--accent-hover);
}

.btn-meaning:active {
  transform: scale(0.98);
}

.extra-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 481px) {
  .extra-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
  }
}

@media (min-width: 769px) {
  .extra-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
}

.extra-item {
  border: none;
  padding: 0;
  margin: 0;
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  animation: fadeUp 0.4s var(--ease) forwards;
  transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.extra-item:hover {
  box-shadow: var(--shadow-hover);
  transform: scale(1.02);
}

.extra-item:active {
  transform: scale(0.98);
}

.extra-item__frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-soft);
}

.extra-item__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration) var(--ease);
}

.extra-item--rotated .extra-item__img {
  width: 142%;
  height: 142%;
  object-fit: cover;
}

.extra-item__badge {
  position: absolute;
  bottom: 0.45rem;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-hover);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(61, 50, 41, 0.12);
  pointer-events: none;
  white-space: nowrap;
}

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem calc(1.5rem + var(--safe-bottom));
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 35, 28, 0.55);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.modal.is-open .modal-backdrop {
  opacity: 1;
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 100dvh;
  margin: 0;
  background: var(--bg);
  opacity: 0;
  transform: scale(0.97);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.modal.is-open .modal-panel {
  opacity: 1;
  transform: scale(1);
}

@media (min-width: 769px) {
  .modal {
    padding: 2rem;
    align-items: center;
  }

  .modal-panel {
    height: auto;
    max-height: 90dvh;
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  padding: calc(0.85rem + var(--safe-top)) 1rem 0.85rem;
  background: var(--card);
  border-bottom: 1px solid rgba(61, 50, 41, 0.08);
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.modal-close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.modal-close:hover {
  background: rgba(212, 132, 95, 0.2);
}

.modal-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1rem calc(1.5rem + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.modal-slide {
  margin-bottom: 2rem;
  animation: fadeUp 0.35s var(--ease) both;
}

.modal-slide:last-child {
  margin-bottom: 0;
}

.modal-slide__img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow);
}

.modal-slide__text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

@media (max-width: 480px) {
  .modal-slide__text {
    font-size: 15px;
  }
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top));
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 15, 12, 0.85);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

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

.lightbox-close {
  position: absolute;
  top: calc(0.75rem + var(--safe-top));
  right: calc(0.75rem + var(--safe-right));
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: calc(100dvh - 3rem);
  object-fit: contain;
  border-radius: 8px;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.lightbox.is-open .lightbox-img {
  opacity: 1;
  transform: scale(1);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .work-card,
  .extra-item {
    opacity: 1;
    transform: none;
  }
}
