/* ============================================
   組長へクエスチョン - Neo-Tokyo Underground
   Design System: style.css v2 — Full Polish
   ============================================ */

/* ========== Google Fonts ========== */
@import url('https://fonts.googleapis.com/css2?family=Epilogue:wght@900&family=Be+Vietnam+Pro:wght@400;600;700&family=Noto+Sans+JP:wght@400;700&display=swap');

/* ========== Design Tokens ========== */
:root {
    --primary: #c21c38;
    --primary-glow: rgba(194, 28, 56, 0.3);
    --primary-deep: #8a1428;
    --secondary: #fff100;
    --secondary-glow: rgba(255, 241, 0, 0.15);
    --on-surface: #e5e2e1;
    --on-surface-muted: #a0a0a0;
    --outline: #555;

    --bg: #0e0e0e;
    --surface-low: #181818;
    --surface-high: #222222;
    --surface-highest: #2e2e2e;

    --react-heart: #e84057;
    --react-laugh: #fbbf24;
    --react-surprise: #60a5fa;
    --react-fire: #f97316;

    --rank-gold: #ffd700;
    --rank-silver: #b8b8b8;
    --rank-bronze: #cd7f32;

    --font-display: 'Epilogue', 'Noto Sans JP', sans-serif;
    --font-body: 'Be Vietnam Pro', 'Noto Sans JP', sans-serif;

    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

    --shadow-clay:
        0 12px 32px rgba(0,0,0,0.5),
        inset 3px 3px 6px rgba(255,255,255,0.04),
        inset -3px -3px 6px rgba(0,0,0,0.4);
    --shadow-clay-hover:
        0 16px 40px rgba(0,0,0,0.55),
        inset 3px 3px 6px rgba(255,255,255,0.06),
        inset -3px -3px 6px rgba(0,0,0,0.4);
    --shadow-clay-simple:
        0 6px 12px rgba(0,0,0,0.35);
    --shadow-fab:
        0 6px 20px rgba(194,28,56,0.4),
        inset 2px 2px 4px rgba(255,255,255,0.15),
        inset -1px -1px 3px rgba(0,0,0,0.3);
    --shadow-fab-press:
        0 2px 8px rgba(194,28,56,0.3),
        inset -2px -2px 6px rgba(0,0,0,0.4),
        inset 1px 1px 2px rgba(255,255,255,0.05);

    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
    --radius-pill: 9999px;

    --ghost-border: 1px solid rgba(255,255,255,0.05);
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--on-surface);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* ========== Typography ========== */
.headline-md {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

/* ========== Top Bar (sticky) ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--sp-2) var(--sp-4);
    background: rgba(14, 14, 14, 0.85);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    text-align: center;
    border-bottom: var(--ghost-border);
}

.topbar-logo {
    height: 72px;
    width: auto;
    filter: invert(1);
    display: inline-block;
    cursor: pointer;
    transition: opacity 0.2s;
}
.topbar-logo:active { opacity: 0.7; }

.topbar-link {
    position: absolute;
    right: var(--sp-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--on-surface-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-low);
    border: var(--ghost-border);
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.topbar-link:hover { color: var(--on-surface); background: var(--surface-high); }

/* ========== Ranking Section (with hero background) ========== */
.hero-bg {
    background: url('./background.jpg') center center / cover no-repeat;
    position: relative;
}

.ranking-section {
    position: relative;
    z-index: 1;
    padding: var(--sp-5) var(--sp-4) var(--sp-5);
}

.ranking-header {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--secondary);
    margin-bottom: var(--sp-2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.ranking-scroll {
    display: flex;
    gap: var(--sp-3);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: var(--sp-3) 0 var(--sp-2);
    scrollbar-width: none;
}
.ranking-scroll::-webkit-scrollbar { display: none; }

.ranking-card {
    flex: 0 0 180px;
    scroll-snap-align: start;
    background: var(--surface-high);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-clay);
    border: var(--ghost-border);
}
.ranking-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-clay-hover);
}

/* Ranking card 1-3 get a colored top accent */
.ranking-card[data-rank="1"] { border-top: 2px solid var(--rank-gold); }
.ranking-card[data-rank="2"] { border-top: 2px solid var(--rank-silver); }
.ranking-card[data-rank="3"] { border-top: 2px solid var(--rank-bronze); }

.ranking-badge {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: var(--sp-2);
}
.ranking-badge[data-rank="1"] {
    color: var(--rank-gold);
    text-shadow: 0 0 16px rgba(255,215,0,0.5), 0 0 4px rgba(255,215,0,0.3);
}
.ranking-badge[data-rank="2"] {
    color: var(--rank-silver);
    text-shadow: 0 0 10px rgba(184,184,184,0.4);
}
.ranking-badge[data-rank="3"] {
    color: var(--rank-bronze);
    text-shadow: 0 0 10px rgba(205,127,50,0.4);
}
.ranking-badge[data-rank="4"],
.ranking-badge[data-rank="5"] { color: var(--outline); font-size: 1rem; }

.ranking-question {
    font-size: 0.75rem;
    color: var(--on-surface);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.45;
}

.ranking-reactions {
    margin-top: var(--sp-2);
    font-size: 0.65rem;
    color: var(--on-surface-muted);
}

/* ========== Category Filter ========== */
.category-filter {
    display: flex;
    gap: 6px;
    padding: var(--sp-3) var(--sp-4);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.category-filter::-webkit-scrollbar { display: none; }

.category-pill {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface-low);
    color: var(--on-surface-muted);
    border: var(--ghost-border);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.category-pill:hover { color: var(--on-surface); background: var(--surface-high); }
.category-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}
.pill-special {
    border-color: rgba(255, 241, 0, 0.15);
    color: var(--secondary);
}
.pill-special.active {
    background: rgba(255, 241, 0, 0.15);
    color: var(--secondary);
    border-color: rgba(255, 241, 0, 0.3);
    box-shadow: 0 0 12px var(--secondary-glow);
}

/* ========== Search Bar ========== */
.search-container { padding: 0 var(--sp-4) var(--sp-3); }

.search-bar {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--surface-low);
    border: var(--ghost-border);
    border-radius: var(--radius-sm);
    color: var(--on-surface);
    font-size: 16px; /* iOS自動ズーム防止 */
    font-family: var(--font-body);
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.search-bar::placeholder { color: var(--outline); }
.search-bar:focus {
    box-shadow: 0 0 0 2px var(--primary-glow);
    border-color: rgba(194,28,56,0.2);
}

.search-wrapper { position: relative; }
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--outline);
    font-size: 0.85rem;
    pointer-events: none;
}

/* ========== Q&A Card List ========== */
.qa-list {
    padding: var(--sp-2) var(--sp-4) var(--sp-12);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.qa-card {
    background: var(--surface-high);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    box-shadow: var(--shadow-clay);
    will-change: transform;
    border: var(--ghost-border);
}
.qa-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-clay-hover);
}
.qa-card:active { transform: translateY(0); }
.qa-card.offscreen { box-shadow: var(--shadow-clay-simple); }

/* Q prefix accent */
.qa-card-question {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.55;
    margin-bottom: var(--sp-2);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--on-surface);
}

.qa-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.qa-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.tag {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.tag-category {
    background: rgba(194, 28, 56, 0.12);
    color: #e5606e;
    border: 1px solid rgba(194, 28, 56, 0.15);
}

.qa-card-date {
    font-size: 0.65rem;
    color: var(--outline);
    font-variant-numeric: tabular-nums;
}

/* ========== NEW Badge ========== */
.new-badge {
    position: absolute;
    top: -6px;
    right: -4px;
    background: linear-gradient(135deg, #e83050 0%, var(--primary) 100%);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 900;
    padding: 3px 8px;
    border-radius: 4px;
    transform: rotate(12deg);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow:
        0 2px 8px rgba(194, 28, 56, 0.5),
        0 0 20px rgba(194, 28, 56, 0.2);
    z-index: 2;
}

/* ========== Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 200;
    justify-content: center;
    align-items: flex-end;
    padding: 0;
}
.modal-overlay.active { display: flex; }

.modal-panel {
    background: var(--surface-high);
    background: linear-gradient(180deg, var(--surface-highest) 0%, var(--surface-high) 8%, var(--surface-high) 100%);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--sp-6);
    position: relative;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: var(--ghost-border);
    border-bottom: none;
}
/* Handle bar indicator */
.modal-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--outline);
    border-radius: 2px;
    margin: 0 auto var(--sp-4);
    opacity: 0.5;
}

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

.modal-close {
    position: absolute;
    top: var(--sp-3);
    right: var(--sp-3);
    background: var(--surface-highest);
    border: none;
    color: var(--on-surface-muted);
    font-size: 1.25rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--primary); color: #fff; }

.modal-question {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1.4;
    margin-bottom: var(--sp-1);
    padding-right: var(--sp-10);
    color: var(--on-surface);
}

.modal-question-meta {
    font-size: 0.7rem;
    color: var(--outline);
    margin-bottom: var(--sp-5);
}

.modal-answer {
    font-size: 0.9rem;
    line-height: 1.85;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: var(--sp-4);
    color: var(--on-surface-muted);
    padding-left: var(--sp-3);
    border-left: 2px solid var(--primary);
}

.modal-categories {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: var(--sp-5);
}

.modal-divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    margin: var(--sp-3) 0;
}

/* ========== Reaction Buttons ========== */
.reactions {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface-highest);
    border: var(--ghost-border);
    color: var(--outline);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    box-shadow:
        inset 2px 2px 4px rgba(255,255,255,0.03),
        inset -2px -2px 4px rgba(0,0,0,0.25);
}
.reaction-btn:hover {
    color: var(--on-surface);
    background: #333;
}

/* Active states with glow */
.reaction-btn.active[data-type="heart"] {
    color: var(--react-heart);
    background: rgba(232, 64, 87, 0.12);
    border-color: rgba(232, 64, 87, 0.2);
    box-shadow: 0 0 12px rgba(232, 64, 87, 0.15);
}
.reaction-btn.active[data-type="laugh"] {
    color: var(--react-laugh);
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.2);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.12);
}
.reaction-btn.active[data-type="surprise"] {
    color: var(--react-surprise);
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.2);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.12);
}
.reaction-btn.active[data-type="fire"] {
    color: var(--react-fire);
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.2);
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.12);
}

.reaction-icon { font-size: 1rem; display: inline-block; }
.reaction-btn.active .reaction-icon { animation: reactionBounce 0.3s ease; }

.reaction-count { font-size: 0.7rem; font-weight: 700; }
.reaction-count.pop { animation: countPop 0.3s ease; }

@keyframes reactionBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
}
@keyframes countPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* ========== Submit Modal ========== */
.submit-concept {
    font-size: 0.7rem;
    line-height: 1.55;
    color: var(--outline);
    margin-bottom: var(--sp-5);
}

.submit-form { display: flex; flex-direction: column; gap: var(--sp-4); }

.form-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--on-surface-muted);
    margin-bottom: var(--sp-1);
    display: block;
}

.form-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface-low);
    border: var(--ghost-border);
    border-radius: var(--radius-sm);
    color: var(--on-surface);
    font-size: 16px; /* 16px未満だとiOSが自動ズームする */
    font-family: var(--font-body);
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.form-input:focus {
    box-shadow: 0 0 0 2px var(--primary-glow);
    border-color: rgba(194,28,56,0.2);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0a0' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}
.form-select option { background: var(--surface-low); color: var(--on-surface); }

.form-textarea { min-height: 130px; resize: vertical; line-height: 1.6; }

.char-counter { text-align: right; font-size: 0.7rem; color: var(--outline); margin-top: 2px; }
.char-counter.warn { color: var(--primary); font-weight: 600; }

.honeypot { position: absolute; left: -9999px; opacity: 0; height: 0; }

/* ========== FAB ========== */
.fab {
    position: fixed;
    bottom: 24px;
    right: 16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e83050 0%, var(--primary) 50%, var(--primary-deep) 100%);
    color: #fff;
    border: none;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 900;
    cursor: pointer;
    z-index: 90;
    transition: transform 0.15s, box-shadow 0.15s, width 0.2s, height 0.2s, opacity 0.2s;
    box-shadow: var(--shadow-fab);
    display: flex;
    align-items: center;
    justify-content: center;
}
.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(194,28,56,0.5), inset 2px 2px 4px rgba(255,255,255,0.2);
}
.fab:active {
    transform: scale(0.93);
    box-shadow: var(--shadow-fab-press);
}
.fab.shrink {
    width: 44px;
    height: 44px;
    opacity: 0.75;
    font-size: 1.1rem;
}

/* ========== Loading Skeleton ========== */
.skeleton {
    background: var(--surface-low);
    border-radius: var(--radius-md);
    height: 100px;
    position: relative;
    overflow: hidden;
    border: var(--ghost-border);
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ========== Thanks Message ========== */
.thanks-message { text-align: center; padding: var(--sp-12) var(--sp-4); }
.thanks-icon { font-size: 2.5rem; margin-bottom: var(--sp-3); }
.thanks-text {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--secondary);
    text-transform: uppercase;
}
.thanks-sub { color: var(--on-surface-muted); font-size: 0.8rem; margin-top: var(--sp-2); }

/* ========== Primary Button ========== */
.btn-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #e83050 0%, var(--primary) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: var(--shadow-fab);
    letter-spacing: 0.02em;
}
.btn-primary:hover {
    box-shadow: 0 8px 24px rgba(194,28,56,0.45);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ========== Empty State ========== */
.empty-state { text-align: center; padding: var(--sp-12) var(--sp-4); color: var(--outline); }
.empty-state-icon { font-size: 2rem; margin-bottom: var(--sp-3); opacity: 0.5; }

/* ========== Desktop ========== */
@media (min-width: 768px) {
    .topbar { padding: var(--sp-3) var(--sp-6); }
    .topbar-logo { height: 80px; }

    .ranking-section { padding: var(--sp-6) var(--sp-6) var(--sp-4); }
    .ranking-card { flex: 0 0 220px; }

    .category-filter { padding: var(--sp-3) var(--sp-6); }
    .search-container { padding: 0 var(--sp-6) var(--sp-3); }

    .qa-list {
        padding: var(--sp-2) var(--sp-6) var(--sp-12);
        max-width: 720px;
        margin: 0 auto;
    }

    .modal-overlay { align-items: center; padding: var(--sp-6); }
    .modal-panel {
        border-radius: var(--radius-xl);
        border-bottom: var(--ghost-border);
    }
    .modal-panel::before { display: none; }

    @keyframes modalSlideUp {
        from { transform: scale(0.96); opacity: 0; }
        to { transform: scale(1); opacity: 1; }
    }
}
