/* === design_test_version_1/assets/style.css === */
/* Mobile-first redesign of COTTOU — Yahoo Mobile-style compact UI */

/* === 1. CSS Variables (Default: Vintage Poster theme) === */
:root {
  --font-body: "Merriweather", "Georgia", serif;
  --font-display: "Staatliches", "Impact", sans-serif;
  --font-brand: "Staatliches", "Impact", sans-serif;
  --body-bg: linear-gradient(135deg, #f4e5d3 0%, #d9c4a8 100%);
  --text: #8b4513;
  --muted: #a06030;
  --accent: #8b4513;
  --accent-2: #a06030;
  --accent-3: #c08050;
  --line: rgba(139, 69, 19, 0.2);
  --glow: rgba(139, 69, 19, 0.2);
  --brand-grad: linear-gradient(135deg, #8b4513, #a06030);
  --brand-mark-text: #f4e5d3;
  --brand-mark-shadow: 0 8px 24px rgba(139, 69, 19, 0.25);
  --hero-bg: rgba(255, 255, 255, 0.6);
  --hero-border-color: rgba(139, 69, 19, 0.2);
  --hero-shadow: 0 24px 60px rgba(139, 69, 19, 0.1);
  --input-bg: rgba(255, 255, 255, 0.8);
  --input-border-color: rgba(139, 69, 19, 0.25);
  --pill-bg: rgba(255, 255, 255, 0.5);
  --pill-border-color: rgba(139, 69, 19, 0.2);
  --pill-selected-bg: rgba(139, 69, 19, 0.15);
  --pill-selected-border: rgba(139, 69, 19, 0.5);
  --pill-selected-shadow: 0 12px 24px rgba(139, 69, 19, 0.1);
  --button-bg: linear-gradient(135deg, #8b4513, #a06030);
  --button-text: #f4e5d3;
  --button-shadow: 0 10px 20px rgba(139, 69, 19, 0.3);
  --cta-bg: rgba(255, 255, 255, 0.5);
  --cta-border: rgba(139, 69, 19, 0.2);
  --cta-text: #a06030;
  --card-text: #8b4513;
  --card-muted: #a06030;
  --card-bg: rgba(255, 255, 255, 0.6);
}

/* === 2. Base Reset === */
*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--body-bg);
  min-height: 100vh;
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
  background: none;
}

[hidden] { display: none !important; }

/* === 3. App Header (sticky) === */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--hero-bg);
  border-bottom: 1px solid var(--hero-border-color);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-inner {
  padding: env(safe-area-inset-top) 12px 0;
}

/* Row 1: Brand + Controls */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--brand-grad);
  color: var(--brand-mark-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: var(--brand-mark-shadow);
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Desktop nav (hidden on mobile) */
.desktop-nav {
  display: none;
}

/* Row 2: Search form */
.header-search-row {
  padding: 6px 0;
}

.search-form {
  display: flex;
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border-color);
  border-radius: 10px;
  padding: 4px 4px 4px 12px;
  min-height: 44px;
}

.search-wrap textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  min-height: 36px;
  padding: 4px 0;
}

.search-wrap textarea::placeholder {
  color: var(--muted);
}

.search-submit {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--button-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.search-submit:active {
  opacity: 0.75;
}

.search-submit svg {
  width: 16px;
  height: 16px;
}

/* Row 3: Engine pills (horizontal scroll) */
.engine-row {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 8px;
}

.engine-row::-webkit-scrollbar { display: none; }

.engine-group {
  display: flex;
  gap: 6px;
  width: max-content;
}

.engine-pill {
  display: flex;
  align-items: center;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border-color);
  border-radius: 20px;
  padding: 0 12px;
  height: 28px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.engine-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.engine-pill.is-selected {
  background: var(--pill-selected-bg);
  border-color: var(--pill-selected-border);
  color: var(--text);
}

/* === 4. Theme Toggle Button === */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border-color);
  color: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
}

@media (hover: hover) {
  .theme-toggle:hover {
    color: var(--text);
    border-color: var(--accent);
  }
}

/* === 5. Language Selector === */
.lang-selector {
  position: relative;
}

.lang-current {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border-color);
  color: var(--muted);
  padding: 0 10px;
  border-radius: 20px;
  font-size: 11px;
  height: 32px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

@media (hover: hover) {
  .lang-current:hover {
    color: var(--text);
    border-color: var(--accent);
  }
}

.lang-arrow {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
}

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--hero-bg);
  border: 1px solid var(--hero-border-color);
  border-radius: 10px;
  padding: 4px;
  min-width: 120px;
  z-index: 200;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.lang-selector.is-open .lang-menu {
  display: flex;
  flex-direction: column;
}

.lang-option {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.lang-option:hover,
.lang-option.is-active {
  background: var(--pill-selected-bg);
  color: var(--text);
}

/* === 6. Page Content === */
.page-content {
  padding: 8px 12px calc(56px + env(safe-area-inset-bottom) + 12px);
  max-width: 1100px;
  margin: 0 auto;
}

/* === 7. Section Title === */
.section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 14px 0 5px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 5px;
}

/* === 8. Links Grid === */
.links-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 0;
}

/* === 9. Link Card (44px minimum — Apple HIG) === */
.link-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--card-text);
  transition: border-color 0.15s, background 0.15s;
}

.link-card:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .link-card:hover {
    border-color: var(--accent);
    background: var(--pill-selected-bg);
  }
}

.link-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  line-height: 1;
}

.link-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* === 10. Tab Bar (fixed bottom, mobile only) === */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--hero-bg);
  border-top: 1px solid var(--hero-border-color);
  display: flex;
  align-items: stretch;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
  padding: 6px 4px;
  transition: color 0.15s;
}

.tab-item svg {
  width: 22px;
  height: 22px;
}

.tab-item.is-active {
  color: var(--accent);
}

@media (hover: hover) {
  .tab-item:hover {
    color: var(--text);
  }
}

/* === 11. Theme Panel (injected by theme-switcher.js) === */
.theme-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.theme-panel-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.theme-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: var(--hero-bg);
  border-top: 1px solid var(--hero-border-color);
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.theme-panel.is-open {
  transform: translateY(0);
}

.theme-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.theme-panel-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.theme-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--pill-bg);
  border: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-panel-close svg {
  width: 16px;
  height: 16px;
}

.theme-panel-content {
  overflow-y: auto;
  padding: 16px 20px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.theme-option.is-active {
  border-color: var(--accent);
}

.theme-preview {
  display: flex;
  gap: 2px;
  border-radius: 4px;
  overflow: hidden;
  width: 48px;
  height: 24px;
}

.theme-preview-color {
  flex: 1;
}

.theme-name {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

/* === 12. Breakpoints === */

/* 600px: 3-column grid */
@media (min-width: 600px) {
  .links-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .theme-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .header-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-content {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* 768px: 4-column grid, tab bar hidden, desktop nav */
@media (min-width: 768px) {
  .links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .tab-bar {
    display: none;
  }

  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    margin-left: 16px;
  }

  .desktop-nav a {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--muted);
    border: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
  }

  .desktop-nav a.is-active {
    color: var(--accent);
    border-color: var(--accent);
  }

  .header-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
  }

  .search-form {
    flex: 1;
  }

  .engine-row {
    padding-bottom: 0;
    flex-shrink: 0;
  }

  .page-content {
    padding-bottom: 32px;
  }

  /* Theme panel as popover on desktop */
  .theme-panel {
    left: auto;
    right: 20px;
    bottom: 20px;
    width: 380px;
    border-radius: 16px;
    border: 1px solid var(--hero-border-color);
    transform: scale(0.95) translateY(8px);
    opacity: 0;
    transition: transform 0.2s, opacity 0.2s;
  }

  .theme-panel.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@media (min-width: 768px) and (hover: hover) {
  .desktop-nav a:hover {
    color: var(--text);
    border-color: var(--line);
  }
}

/* 1100px: 5-column grid */
@media (min-width: 1100px) {
  .links-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding-left: 0;
    padding-right: 0;
  }

  .page-content {
    padding-left: 0;
    padding-right: 0;
  }

  /* Outer header needs padding so inner content is centered */
  .app-header {
    padding-left: calc((100% - 1100px) / 2);
    padding-right: calc((100% - 1100px) / 2);
  }
}

/* === 13. Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
