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

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-hover: #f5f6f8;
  --border: #dde2e8;
  --text: #001722;
  --text-muted: #5c6570;
  --accent: #f68b1f;
  --accent-soft: #ffa94d;
  --accent-dim: rgba(246, 139, 31, 0.14);
  --accent-glow: rgba(246, 139, 31, 0.4);
  --navy: #001722;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --header-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --grid-gap: 1rem;
  --max-width: 1200px;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
  --shadow-sm: 0 2px 8px rgba(0, 23, 34, 0.06);
  --shadow-md: 0 8px 28px rgba(0, 23, 34, 0.1);
  --shadow-lg: 0 16px 48px rgba(0, 23, 34, 0.12);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(ellipse 90% 60% at 100% 0%, rgba(246, 139, 31, 0.09), transparent 45%),
    radial-gradient(ellipse 70% 50% at 0% 100%, rgba(0, 23, 34, 0.04), transparent 40%),
    linear-gradient(165deg, #fafbfc 0%, var(--bg) 45%, #e9edf2 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid rgba(221, 226, 232, 0.8);
  box-shadow: var(--shadow-sm);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  min-height: var(--header-h);
}

.logo-link {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.3s var(--ease-out), opacity 0.2s;
}

@media (hover: hover) {
  .logo-link:hover {
    transform: scale(1.04);
  }
}

.logo-link:active {
  opacity: 0.7;
  transform: scale(0.98);
}

.logo {
  height: 52px;
  width: auto;
  display: block;
}

.header-title {
  grid-column: 3;
  justify-self: end;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  padding: 0.4rem 0.75rem;
  background: var(--accent-dim);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(246, 139, 31, 0.2);
}

/* Main */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem calc(2rem + var(--safe-bottom));
  animation: fadeIn 0.5s var(--ease-out);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideImageIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover,
.breadcrumb a:focus-visible {
  color: var(--accent);
}

.breadcrumb-sep {
  opacity: 0.5;
  user-select: none;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
}

/* Section title */
.page-title {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
  color: var(--navy);
}

/* Grid (category / item pages) */
.texture-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--grid-gap);
  list-style: none;
}

.texture-grid > li {
  animation: cardEnter 0.55s var(--ease-out) backwards;
}

.texture-grid > li:nth-child(1) { animation-delay: 0.04s; }
.texture-grid > li:nth-child(2) { animation-delay: 0.08s; }
.texture-grid > li:nth-child(3) { animation-delay: 0.12s; }
.texture-grid > li:nth-child(4) { animation-delay: 0.16s; }
.texture-grid > li:nth-child(5) { animation-delay: 0.2s; }
.texture-grid > li:nth-child(6) { animation-delay: 0.24s; }
.texture-grid > li:nth-child(7) { animation-delay: 0.28s; }
.texture-grid > li:nth-child(8) { animation-delay: 0.32s; }
.texture-grid > li:nth-child(9) { animation-delay: 0.36s; }
.texture-grid > li:nth-child(n + 10) { animation-delay: 0.4s; }

/* Tablet: 768px – 1023px */
@media (min-width: 768px) {
  .texture-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.125rem;
  }
}

/* Desktop: 1024px+ */
@media (min-width: 1024px) {
  .texture-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
  }
}

/* Homepage grid — phone / tablet / desktop */
.home-grid {
  --home-grid-gap: clamp(0.75rem, 2vw, 1.25rem);
  --home-grid-max: 100%;
  width: 100%;
  padding-inline: clamp(0.75rem, 3vw, 1.25rem);
  margin-inline: auto;
}

.home-grid .texture-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--home-grid-gap);
  width: 100%;
  max-width: var(--home-grid-max);
  margin-inline: auto;
}

.home-grid .texture-grid > li {
  flex: 0 1 100%;
  width: 100%;
  max-width: 400px;
  animation: cardEnter 0.55s var(--ease-out) backwards;
}

.home-grid .texture-grid > li:nth-child(1) { animation-delay: 0.05s; }
.home-grid .texture-grid > li:nth-child(2) { animation-delay: 0.1s; }
.home-grid .texture-grid > li:nth-child(3) { animation-delay: 0.15s; }
.home-grid .texture-grid > li:nth-child(4) { animation-delay: 0.2s; }
.home-grid .texture-grid > li:nth-child(5) { animation-delay: 0.25s; }
.home-grid .texture-grid > li:nth-child(6) { animation-delay: 0.3s; }
.home-grid .texture-grid > li:nth-child(7) { animation-delay: 0.35s; }
.home-grid .texture-grid > li:nth-child(8) { animation-delay: 0.4s; }
.home-grid .texture-grid > li:nth-child(9) { animation-delay: 0.45s; }

/* Tablet: 2 columns */
@media (min-width: 768px) {
  .home-grid {
    --home-grid-max: 640px;
  }

  .home-grid .texture-grid > li {
    flex: 0 1 calc((100% - var(--home-grid-gap)) / 2);
    width: calc((100% - var(--home-grid-gap)) / 2);
    max-width: none;
  }
}

/* Desktop: 3 columns, wider max */
@media (min-width: 1024px) {
  .home-grid {
    --home-grid-max: 980px;
  }

  .home-grid .texture-grid > li {
    flex: 0 1 calc((100% - 2 * var(--home-grid-gap)) / 3);
    width: calc((100% - 2 * var(--home-grid-gap)) / 3);
  }
}

.grid-item {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid rgba(221, 226, 232, 0.9);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.28s ease,
    background 0.28s ease,
    box-shadow 0.28s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.grid-item:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Mouse / trackpad */
@media (hover: hover) and (pointer: fine) {
  .grid-item:hover {
    border-color: var(--accent);
    background: var(--surface);
    transform: translateY(-6px);
    box-shadow:
      0 14px 28px rgba(0, 23, 34, 0.12),
      0 0 0 1px rgba(246, 139, 31, 0.2);
  }

  .grid-item:hover .grid-thumb::after {
    opacity: 1;
  }

  .grid-item:hover .grid-thumb img {
    transform: scale(1.08);
  }

  .grid-item:hover .grid-label {
    color: var(--accent);
  }

  .grid-item:hover .category-icon {
    transform: scale(1.1);
    color: var(--accent);
  }
}

/* Touch — press feedback (no sticky hover) */
@media (hover: none) {
  .grid-item:active {
    border-color: var(--accent);
    transform: scale(0.97);
    box-shadow:
      0 6px 16px rgba(0, 23, 34, 0.1),
      0 0 0 1px rgba(246, 139, 31, 0.25);
  }

  .grid-item:active .grid-thumb::after {
    opacity: 1;
  }

  .grid-item:active .grid-thumb img {
    transform: scale(1.05);
  }

  .grid-item:active .grid-label {
    color: var(--accent);
  }
}

.grid-thumb {
  aspect-ratio: 1;
  background: var(--surface-hover);
  position: relative;
  overflow: hidden;
}

.grid-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(246, 139, 31, 0) 40%,
    rgba(246, 139, 31, 0.12) 100%
  );
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.grid-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.grid-thumb .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: linear-gradient(145deg, #eef0f3 0%, #e4e7ec 100%);
}

.grid-thumb .placeholder svg {
  width: 40%;
  max-width: 56px;
  opacity: 0.35;
}

.grid-label {
  padding: 0.75rem 0.875rem;
  font-weight: 500;
  font-size: 0.9375rem;
  text-align: center;
  border-top: 1px solid var(--border);
  transition: color 0.28s ease;
}

.grid-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

/* Category cards (home) — text only, no thumb required */
.grid-item--category .grid-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
}

.grid-item--category .category-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
  opacity: 0.9;
  transition: transform 0.28s ease, color 0.28s ease;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: clamp(2rem, 8vw, 3rem) clamp(1rem, 4vw, 1.5rem);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed rgba(246, 139, 31, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  animation: cardEnter 0.6s var(--ease-out);
}

.empty-state h2 {
  font-size: clamp(1.125rem, 4vw, 1.35rem);
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

/* Carousel view */
.page-gallery .main {
  max-width: 1100px;
}

.carousel-section {
  margin: 0;
  animation: fadeIn 0.55s var(--ease-out);
}

.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.carousel-title {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a4a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.carousel-counter {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  padding: 0.45rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: transform 0.35s var(--ease-spring);
}

.carousel-counter.is-ticking {
  animation: counterPop 0.45s var(--ease-spring);
}

@keyframes counterPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.carousel-swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  animation: hintPulse 2.5s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@media (min-width: 1024px) {
  .carousel-swipe-hint {
    display: none;
  }
}

.carousel-stage {
  position: relative;
}

.carousel-progress {
  height: 3px;
  margin-top: 0.65rem;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.carousel-progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  border-radius: inherit;
  transition: width 0.55s var(--ease-out);
}

.swiper.texture-swiper {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(160deg, #f0f2f5 0%, #e4e8ed 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 1024px) {
  .swiper.texture-swiper {
    aspect-ratio: 16 / 10;
  }
}

.swiper.texture-swiper .swiper-wrapper {
  height: 100%;
}

.swiper.texture-swiper .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: hidden;
}

.slide-media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  box-sizing: border-box;
}

.slide-media img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 8px 24px rgba(0, 23, 34, 0.12));
}

/* Subtle zoom when slide becomes active */
.swiper.texture-swiper .swiper-slide-active .slide-media img {
  animation: carouselImageIn 0.45s var(--ease-out);
}

@keyframes carouselImageIn {
  from {
    opacity: 0.85;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.swiper.texture-swiper .swiper-button-prev,
.swiper.texture-swiper .swiper-button-next {
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 23, 34, 0.12);
  width: clamp(40px, 10vw, 48px);
  height: clamp(40px, 10vw, 48px);
  border-radius: 50%;
  backdrop-filter: blur(10px);
  transition:
    transform 0.3s var(--ease-out),
    background 0.25s ease,
    color 0.25s ease,
    box-shadow 0.3s ease;
}

.swiper.texture-swiper .swiper-button-prev::after,
.swiper.texture-swiper .swiper-button-next::after {
  font-size: clamp(0.875rem, 2.5vw, 1.125rem);
  font-weight: 700;
}

@media (hover: hover) {
  .swiper.texture-swiper .swiper-button-prev:hover,
  .swiper.texture-swiper .swiper-button-next:hover {
    background: var(--accent);
    color: #ffffff;
    transform: scale(1.08);
    box-shadow: 0 6px 20px var(--accent-glow);
  }
}

.swiper.texture-swiper .swiper-button-prev:active,
.swiper.texture-swiper .swiper-button-next:active {
  transform: scale(0.95);
}

.swiper.texture-swiper .swiper-pagination-bullet {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  opacity: 0.45;
  transition:
    transform 0.3s var(--ease-out),
    opacity 0.3s ease,
    background 0.3s ease;
}

.swiper.texture-swiper .swiper-pagination-bullet-active {
  background: var(--accent);
  opacity: 1;
  transform: scale(1.25);
}

.swiper.texture-swiper .swiper-pagination {
  bottom: clamp(10px, 2vw, 16px) !important;
}

/* Thumbnail strip under carousel */
.thumb-strip {
  display: flex;
  gap: 0.625rem;
  margin-top: 1.25rem;
  padding: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.thumb-strip::-webkit-scrollbar {
  height: 4px;
}

.thumb-strip button {
  flex: 0 0 clamp(56px, 14vw, 72px);
  width: clamp(56px, 14vw, 72px);
  height: clamp(56px, 14vw, 72px);
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  scroll-snap-align: start;
  transition:
    border-color 0.3s ease,
    opacity 0.3s ease,
    transform 0.3s var(--ease-out),
    box-shadow 0.3s ease;
}

.thumb-strip button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s var(--ease-out);
}

.thumb-strip button.active {
  border-color: var(--accent);
  opacity: 1;
  transform: scale(1.06);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.thumb-strip button:not(.active) {
  opacity: 0.5;
}

@media (hover: hover) {
  .thumb-strip button:hover {
    opacity: 1;
    transform: scale(1.04);
    border-color: rgba(246, 139, 31, 0.5);
  }

  .thumb-strip button:hover img {
    transform: scale(1.08);
  }
}

.thumb-strip button:active {
  transform: scale(0.96);
}

/* Back + breadcrumb row */
.page-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.25rem;
  padding: 0.65rem 0;
}

.page-nav .breadcrumb {
  margin-bottom: 0;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem 0.5rem 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.25s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .btn-back:hover {
    border-color: rgba(246, 139, 31, 0.45);
    box-shadow: var(--shadow-md);
    transform: translateX(-2px);
  }
}

.btn-back:hover,
.btn-back:focus-visible {
  color: var(--accent);
  outline: none;
}

.btn-back svg {
  width: 1.125rem;
  height: 1.125rem;
  transition: transform 0.3s var(--ease-out);
}

@media (hover: hover) {
  .btn-back:hover svg {
    transform: translateX(-3px);
  }
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 40vh;
  color: var(--text-muted);
}

.loading.hidden {
  display: none;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error */
.error-box {
  padding: 1.25rem;
  background: rgba(180, 60, 60, 0.08);
  border: 1px solid rgba(180, 60, 60, 0.25);
  border-radius: var(--radius);
  color: #a83232;
  font-size: 0.9375rem;
}

/* ——— Responsive ——— */
@media (max-width: 767px) {
  :root {
    --header-h: 64px;
  }

  .header-inner {
    padding: 0.65rem 1rem;
    grid-template-columns: 1fr auto;
  }

  .logo-link {
    grid-column: 1;
    justify-self: start;
  }

  .header-title {
    grid-column: 2;
    font-size: 0.9375rem;
  }

  .logo {
    height: 42px;
  }

  .main {
    padding: 1rem 0.875rem calc(1.25rem + var(--safe-bottom));
  }

  .page-title {
    font-size: 1.25rem;
  }

  .page-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .breadcrumb {
    font-size: 0.8125rem;
  }

  .carousel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .swiper.texture-swiper .swiper-button-prev,
  .swiper.texture-swiper .swiper-button-next {
    --swiper-navigation-size: 28px;
  }
}

@media (max-width: 380px) {
  .grid-label {
    font-size: 0.875rem;
    padding: 0.625rem 0.5rem;
  }
}

@media (min-width: 768px) {
  .page-nav {
    margin-bottom: 1rem;
  }
}

/* Tablet-only tweaks */
@media (min-width: 768px) and (max-width: 1023px) {
  .main {
    max-width: 900px;
  }
}

@media (min-width: 1024px) {
  .main {
    max-width: var(--max-width);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .main,
  .home-grid .texture-grid > li,
  .texture-grid > li,
  .empty-state,
  .carousel-section,
  .carousel-swipe-hint,
  .carousel-counter.is-ticking,
  .swiper.texture-swiper .swiper-slide-active .slide-media img {
    animation: none;
  }

  .carousel-progress__bar {
    transition: none;
  }
}
