/* ===== Global Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", sans-serif;
  background-color: #f5f5f5;
  color: #333;
  overflow: hidden;
}

/* ===== Header & Search ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: white;
  padding: 1.2rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.app-title {
  font-size: 1.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.site-identity {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.site-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.company-home-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.company-home-link:hover,
.company-home-link:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  border-color: #fff;
  outline: none;
}

.brand-partner-note {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.search-container {
  flex: 1;
  position: relative;
  max-width: 500px;
}

.search-input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 1.2rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  outline: none;
  background: rgba(255, 255, 255, 0.95);
  transition: all 0.3s ease;
}

.search-input:focus {
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
  background: white;
}

.search-clear {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
}

.search-clear:hover {
  color: #333;
}

/* ===== Main App Container ===== */
.app-main {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.level {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: scale(1.05);
  overflow-y: auto;
  overflow-x: hidden;
}

.level.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.level.exit-left {
  transform: translateX(-100%);
}

.level.exit-right {
  transform: translateX(100%);
}

/* ===== Level 0: Main Category Grid (4-split) ===== */
.level-0 {
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eef7 100%);
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: clamp(1rem, 2vw, 1.75rem);
  padding: clamp(1rem, 2.5vw, 2.5rem);
  height: 100%;
  align-content: stretch;
}

.category-block {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(30, 60, 114, 0.09);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.category-block::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Category specific colors */
.category-block.lifestyle .category-icon { color: #FF6B6B; }
.category-block.lifestyle .category-featured-item { border-left-color: #FF6B6B; }

.category-block.housing .category-icon { color: #4ECDC4; }
.category-block.housing .category-featured-item { border-left-color: #4ECDC4; }

.category-block.business .category-icon { color: #FFE66D; }
.category-block.business .category-featured-item { border-left-color: #FFE66D; }

.category-block.rights .category-icon { color: #95E1D3; }
.category-block.rights .category-featured-item { border-left-color: #95E1D3; }

.category-block:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 36px rgba(30, 60, 114, 0.16);
}

.category-block:hover::before {
  opacity: 1;
}

.category-visual {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(180px, 1fr);
  align-items: center;
  padding: 0;
  text-align: center;
}

.category-icon {
  height: 100%;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.category-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.45s ease;
}

.category-block:hover .category-icon img {
  transform: scale(1.025);
}

.category-svg-icon {
  width: 100%;
  height: 100%;
  color: currentColor;
}

.category-title {
  font-size: clamp(1.05rem, 1.35vw, 1.45rem);
  font-weight: 700;
  color: #1e3c72;
  line-height: 1.35;
  letter-spacing: 0.02em;
  padding: 1.5rem 1.8rem;
}

.category-arrow {
  position: absolute;
  right: 1.4rem;
  bottom: 1.15rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #2a5298;
  background: rgba(42, 82, 152, 0.08);
  font-size: 1.15rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.category-block:hover .category-arrow {
  transform: translateX(3px);
  background: rgba(42, 82, 152, 0.14);
}

.category-featured-list {
  flex: 1;
  background: #fdfbf7;
  padding: 1.5rem;
  overflow-y: auto;
}

.category-featured-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #FF6B6B;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-featured-items {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.category-featured-item {
  background: white;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border-left: 3px solid #1e3c72;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  line-height: 1.3;
}

.category-featured-item:hover {
  background: #f5f5f5;
  transform: translateX(4px);
}

.category-featured-item-title {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.2rem;
}

.category-featured-item-desc {
  font-size: 0.8rem;
  color: #666;
}

.category-meta {
  margin-bottom: 0.5rem;
}

.category-description {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.4;
  margin-bottom: 1rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

.category-block:hover .category-description {
  opacity: 1;
  transform: translateY(0);
}

.category-count-primary {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ff6b6b;
  margin-bottom: 0.3rem;
}

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}

.category-tag {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  background: rgba(42, 82, 152, 0.1);
  color: #2a5298;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(42, 82, 152, 0.2);
}

.category-count {
  font-size: 0.85rem;
  color: #999;
  margin-top: 0.5rem;
}

/* Category-specific colors */
.category-block.lifestyle { border-top: 5px solid #ff6b6b; }
.category-block.housing { border-top: 5px solid #4ecdc4; }
.category-block.business { border-top: 5px solid #f2b134; }
.category-block.rights { border-top: 5px solid #9b6bc4; }

/* ===== Level 1: Subcategory Cards ===== */
.level-1 {
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eef7 100%);
}

.level-header {
  background: white;
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.back-button {
  background: #2a5298;
  color: white;
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.back-button:hover {
  background: #1e3c72;
  transform: translateX(-2px);
}

.breadcrumb {
  font-size: 0.9rem;
  color: #666;
}

.breadcrumb-item {
  margin: 0 0.3rem;
}

.breadcrumb-separator {
  color: #ccc;
  margin: 0 0.5rem;
}

.subcategory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
  justify-content: center;
  gap: 1.4rem;
  padding: clamp(2rem, 5vh, 4rem) 2rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.subcategory-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem 1.25rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 7px 22px rgba(30, 60, 114, 0.09);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  border-top: 4px solid #2a5298;
  min-height: 205px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}

.subcategory-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 30px rgba(30, 60, 114, 0.16);
}

.subcategory-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef4fb;
  color: #2a5298;
}

.subcategory-icon svg {
  width: 66px;
  height: 66px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.subcategory-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e3c72;
  margin: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.subcategory-arrow {
  position: absolute;
  right: 1rem;
  bottom: 0.85rem;
  color: #2a5298;
  font-size: 1.05rem;
  transition: transform 0.2s ease;
}

.subcategory-card:hover .subcategory-arrow {
  transform: translateX(3px);
}

.subcategory-card.lifestyle { border-top-color: #ff6b6b; }
.subcategory-card.lifestyle .subcategory-icon {
  color: #d9535f;
  background: #fff0f1;
}

.subcategory-card.housing { border-top-color: #4ecdc4; }
.subcategory-card.housing .subcategory-icon {
  color: #258f88;
  background: #eaf9f7;
}

.subcategory-card.business { border-top-color: #f2b134; }
.subcategory-card.business .subcategory-icon {
  color: #b77900;
  background: #fff7e3;
}

.subcategory-card.rights { border-top-color: #9b6bc4; }
.subcategory-card.rights .subcategory-icon {
  color: #76509d;
  background: #f5edfb;
}

.subcategory-description {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ===== Level 2: Ordinance Cards ===== */
.level-2 {
  background: #fafafa;
  padding-top: 5rem;
}

.ordinance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  padding: 0 2rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.ordinance-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  border-top: 4px solid #2a5298;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
}

.ordinance-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.ordinance-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e3c72;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ordinance-short-title {
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
  margin: 0.5rem 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ordinance-summary {
  font-size: 0.95rem;
  color: #666;
  line-height: 1.5;
  flex: 1;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ordinance-target {
  font-size: 0.85rem;
  color: #555;
  background: #f5f5f5;
  padding: 0.5rem;
  border-radius: 4px;
  margin: 0.5rem 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ordinance-footer {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.penalty-badge {
  display: inline-block;
  background: #ff6b6b;
  color: white;
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.penalty-badge.none {
  background: #ccc;
}

.ordinance-action {
  display: flex;
  width: 100%;
  margin-top: 0.5rem;
}

.ordinance-action-btn {
  flex: 1;
  display: inline-block;
  padding: 0.7rem 1rem;
  background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: none;
  text-align: center;
  box-shadow: 0 2px 8px rgba(42, 82, 152, 0.2);
  cursor: pointer;
}

.ordinance-action-btn:hover {
  background: linear-gradient(135deg, #1e3c72 0%, #0f1f47 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(42, 82, 152, 0.3);
}

.ordinance-action-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(42, 82, 152, 0.2);
}

/* Legacy support for old ordinance-links */
.ordinance-links {
  display: flex;
  gap: 0.5rem;
}

.ordinance-link {
  display: inline-block;
  padding: 0.5rem 0.8rem;
  background: #e3f2fd;
  color: #1976d2;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  border: 1px solid #bbdefb;
}

.ordinance-link:hover {
  background: #1976d2;
  color: white;
  border-color: #1976d2;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  background: #f0f0f0;
  color: #666;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag:hover {
  background: #2a5298;
  color: white;
}

/* ===== Level Search: Search Results ===== */
.level-search {
  background: #fafafa;
  padding-top: 5rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .app-title {
    font-size: 1.4rem;
  }

  .site-identity {
    width: 100%;
  }

  .site-title-row {
    justify-content: space-between;
  }

  .app-main {
    top: 145px;
  }

  .search-container {
    width: 100%;
    max-width: none;
  }

  .category-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 1rem;
    padding: 1rem;
  }

  .category-block {
    padding: 0;
    min-height: 230px;
  }

  .category-icon {
    font-size: inherit;
  }

  .category-title {
    font-size: 1.2rem;
  }

  .category-visual {
    grid-template-columns: minmax(0, 1.6fr) minmax(145px, 0.9fr);
  }

  .category-description {
    display: none;
  }

  .level-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .back-button {
    width: 100%;
    text-align: center;
  }

  .subcategory-grid {
    grid-template-columns: 1fr;
    padding: 0 1rem 1rem;
  }

  .ordinance-grid {
    grid-template-columns: 1fr;
    padding: 0 1rem 1rem;
  }

  .ordinance-card {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0.8rem 0;
  }

  .header-content {
    padding: 0 1rem;
  }

  .app-title {
    font-size: 1.1rem;
  }

  .company-home-link {
    min-height: 28px;
    padding: 0.28rem 0.58rem;
    font-size: 0.7rem;
  }

  .brand-partner-note {
    font-size: 0.64rem;
  }

  .app-main {
    top: 130px;
  }

  .search-input {
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
  }

  .category-grid {
    padding: 0.8rem;
    gap: 0.8rem;
  }

  .category-icon {
    height: 165px;
    font-size: inherit;
  }

  .category-title {
    font-size: 1rem;
    padding: 1rem 2.5rem 1rem 1rem;
  }

  .category-visual {
    grid-template-columns: 1fr;
    grid-template-rows: 165px auto;
  }

  .category-block {
    min-height: 220px;
  }

  .level-1, .level-2, .level-search {
    padding-top: 80px;
  }

  .level-header {
    padding: 1rem;
  }

  .breadcrumb {
    font-size: 0.8rem;
  }

  .ordinance-card {
    padding: 1rem;
    font-size: 0.9rem;
  }

  .ordinance-title {
    font-size: 0.9rem;
  }

  .ordinance-short-title {
    font-size: 0.8rem;
  }

  .ordinance-summary {
    font-size: 0.85rem;
  }

  .penalty-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }

  .ordinance-links {
    flex-direction: column;
    width: 100%;
  }

  .ordinance-link {
    width: 100%;
    text-align: center;
  }
}

/* ===== Animations ===== */
@keyframes zoomIn {
  from {
    transform: scale(1.05);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

.ordinance-card {
  animation: fadeIn 0.4s ease forwards;
}

.ordinance-card:nth-child(2) {
  animation-delay: 0.05s;
}

.ordinance-card:nth-child(3) {
  animation-delay: 0.1s;
}

.ordinance-card:nth-child(n+4) {
  animation-delay: 0.15s;
}
