/* ==========================================================================
   五島Stock — Design tokens & global styles
   ========================================================================== */

:root {
  --color-bg-page:         #f5f4f0;
  --color-bg-card:         #ffffff;
  --color-bg-muted:        #f0efeb;
  --color-border:          #e8e6df;
  --color-text-primary:    #1a1a18;
  --color-text-secondary:  #666660;
  --color-text-muted:      #999994;
  --color-accent:          #1a1a18;
  --color-sub:             #3c3489;
  --color-pack:            #854f0b;
  --radius-card:           10px;
  --radius-btn:            7px;
  --radius-tag:            20px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
}

/* ==========================================================================
   Legacy utilities (used by list/card/form templates — keep)
   ========================================================================== */

.aspect-4-3 { position: relative; padding-bottom: 75%; }
.aspect-4-3 > * {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}

.card-hover { transition: box-shadow 0.25s ease, transform 0.25s ease; }
.card-hover:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transform: translateY(-3px);
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-settling { opacity: 0.6; }

input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
}

button:active, a:active { transform: scale(0.98); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease-out; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* ==========================================================================
   Asset detail page
   ========================================================================== */

.detail-page {
  background: var(--color-bg-page);
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 0;
}

/* ---------- photo column ---------- */

.photo-col { min-width: 0; }

.photo-wrap {
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: #000;
}

.photo-wrap img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: bottom;
  user-select: none;
  -webkit-user-drag: none;
}

.photo-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.photo-overlay .overlay-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.photo-overlay .overlay-actions button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}
.photo-overlay .overlay-actions button:hover { background: rgba(0, 0, 0, 0.65); }
.photo-overlay .overlay-actions button svg { width: 14px; height: 14px; }
.photo-overlay .overlay-actions button.is-active { color: #ff6b6b; }

.photo-overlay .asset-code {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fff;
  opacity: 0.4;
  letter-spacing: 0.05em;
  pointer-events: auto;
}

.photo-meta { padding-top: 14px; }

.breadcrumb {
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.breadcrumb a { color: inherit; text-decoration: none; }
.breadcrumb a:hover { color: var(--color-text-secondary); }
.breadcrumb .sep { opacity: 0.6; }

.tag-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-tag);
  background: var(--color-bg-muted);
  font-size: 12px;
  color: var(--color-text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tag:hover { background: #e6e4dd; }

.report-link {
  margin-top: 10px;
  display: inline-block;
  font-size: 11px;
  color: var(--color-text-muted);
  text-decoration: underline;
}
.report-link:hover { color: var(--color-text-secondary); }

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.purchase-card {
  background: var(--color-bg-card);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 18px;
}

.asset-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  margin: 0 0 12px;
  color: var(--color-text-primary);
}

.size-selector { margin-bottom: 14px; }

.size-selector .label {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.size-options { display: flex; flex-direction: column; gap: 6px; }

.size-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  background: var(--color-bg-card);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
  color: var(--color-text-primary);
  text-align: left;
  width: 100%;
}
.size-row:hover { border-color: #aaa8a0; }
.size-row.is-selected {
  border: 1.5px solid var(--color-accent);
  background: #fafaf8;
  padding: 8.5px 11.5px;
}

.size-row .size-name {
  font-size: 20px;
  font-weight: 500;
  min-width: 36px;
  letter-spacing: 0.02em;
}
.size-row .size-spec {
  flex: 1;
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.3;
}
.size-row .size-price {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary);
}
.size-row .popular-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  background: #e6f1fb;
  color: #0c447c;
  border-radius: 10px;
  vertical-align: middle;
}

.cart-actions { margin-top: 14px; }

.btn-cart {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--color-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease;
}
.btn-cart:hover { opacity: 0.88; }
.btn-cart.is-added { background: #2f7a4a; }

.btn-ghost {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 10px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover { background: var(--color-bg-muted); color: var(--color-text-primary); }
.btn-ghost.is-active { color: #b73a3a; border-color: #e6c0c0; }

.divider {
  border: none;
  border-top: 0.5px solid var(--color-border);
  margin: 14px 0;
}

.meta-list {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.meta-list .row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  gap: 12px;
}
.meta-list .row .k { color: var(--color-text-muted); }
.meta-list .row .v {
  color: var(--color-text-secondary);
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

/* ---------- subscription / pack cards ---------- */

.sub-card {
  background: #f5f4f8;
  border: 0.5px solid #dddcf5;
  border-radius: var(--radius-card);
  padding: 16px;
}
.pack-card {
  background: #fffcf5;
  border: 0.5px solid #fac775;
  border-radius: var(--radius-card);
  padding: 16px;
}

.card-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}
.sub-card .card-badge  { background: #eeedfe; color: var(--color-sub); }
.pack-card .card-badge { background: #faeeda; color: #633806; }

.card-title {
  font-size: 14px;
  font-weight: 500;
  margin: 6px 0 4px;
  color: var(--color-text-primary);
}

.card-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.card-cta {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-btn);
  text-decoration: none;
  transition: background 0.15s ease;
  background: #fff;
  box-sizing: border-box;
}
.sub-card  .card-cta { color: var(--color-sub);  border: 0.5px solid #afa9ec; }
.pack-card .card-cta { color: var(--color-pack); border: 0.5px solid #fac775; }
.sub-card  .card-cta:hover { background: #f3f2fb; }
.pack-card .card-cta:hover { background: #fcf6e8; }

/* ---------- related assets ---------- */

.related-assets {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 40px;
}

.related-section + .related-section { margin-top: 28px; }

.related-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin: 0 0 12px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.related-grid a {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-bg-muted);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.related-grid a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.related-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   Responsive — tablet
   ========================================================================== */

@media (min-width: 768px) and (max-width: 1023.98px) {
  .detail-layout {
    grid-template-columns: 1fr 240px;
    gap: 16px;
    padding: 20px 20px 0;
  }
  .purchase-card { padding: 14px; }
  .pack-card { display: none; }
  .related-grid { grid-template-columns: repeat(4, 1fr); }
  .related-assets { padding: 28px 20px 36px; }
}

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */

@media (max-width: 767.98px) {
  .detail-layout {
    display: block;
    padding: 0;
    max-width: 100%;
  }
  .photo-col { display: contents; }
  .photo-wrap { border-radius: 0; }

  .sidebar {
    position: static;
    display: block;
    padding: 0 16px;
    margin-top: 0;
  }
  .purchase-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin: 0 -16px;
    padding: 16px;
  }

  .size-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .size-row {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 8px;
    gap: 4px;
  }
  .size-row.is-selected { padding: 9.5px 7.5px; }
  .size-row .size-name { font-size: 16px; min-width: 0; }
  .size-row .size-price { font-size: 13px; }
  .size-row .size-spec  { font-size: 10px; }

  .btn-cart { padding: 14px; font-size: 15px; }

  .sub-card, .pack-card { margin: 10px 16px 0; }

  .photo-meta {
    padding: 14px 16px 0;
    order: 3;
  }

  .related-assets { padding: 24px 16px 32px; }
  .related-grid { grid-template-columns: repeat(4, 1fr); }
}
