/**
 * Pitch Accent Visualization Styles
 * 
 * KanjiOS-styled pitch accent diagrams with the characteristic
 * dark theme, subtle glows, and clean modern aesthetic.
 */

/* ═══════════════════════════════════════════════════════════════════════════════
   CONTAINER STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.pitch-accent-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(249, 115, 22, 0.05) 100%);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

.pitch-accent-container:hover {
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.1);
}

/* Clickable pitch accent (plays audio) */
.pitch-accent-container.clickable {
    cursor: pointer;
    user-select: none;
}

.pitch-accent-container.clickable:hover {
    border-color: rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 24px rgba(34, 197, 94, 0.2);
    transform: translateY(-1px);
}

.pitch-accent-container.clickable:active {
    transform: translateY(0);
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.15);
}

/* Sequential mora ping animation - minimal glow pulse, no scaling */
.pitch-accent-svg .pitch-dot.mora-ping {
    opacity: 1 !important;
    animation: moraPingEnhance 0.6s ease-out forwards !important;
}

@keyframes moraPingEnhance {
    0% {
        filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.9));
    }
    100% {
        filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.6));
    }
}

/* Low pitch dots - subtle brightness pulse */
.pitch-accent-svg .pitch-dot.low.mora-ping {
    opacity: 1 !important;
    animation: moraPingEnhanceLow 0.6s ease-out forwards !important;
}

@keyframes moraPingEnhanceLow {
    0% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.4);
    }
    100% {
        filter: brightness(1);
    }
}

/* Mora text highlight during ping - subtle color shift */
.pitch-accent-svg .pitch-mora.mora-highlight {
    animation: moraTextEnhance 0.6s ease-out forwards;
}

@keyframes moraTextEnhance {
    0% {
        fill: #fafafa;
    }
    50% {
        fill: #4ade80;
    }
    100% {
        fill: #fafafa;
    }
}

/* Compact variant */
.pitch-accent-compact {
    padding: 0.5rem 0.75rem;
    gap: 0.25rem;
}

/* Blurred state (for review before answer reveal) */
.pitch-accent-blurred {
    filter: blur(8px);
    opacity: 0.5;
    pointer-events: none;
    transition: filter 0.4s ease, opacity 0.4s ease;
}

.pitch-accent-blurred.revealed,
.pitch-accent-revealed {
    filter: none;
    opacity: 1;
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SVG DIAGRAM STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.pitch-accent-diagram {
    display: flex;
    justify-content: center;
}

.pitch-accent-svg {
    display: block;
}

/* Pitch line animation */
.pitch-accent-svg .pitch-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: pitchLineReveal 0.8s ease-out forwards;
}

@keyframes pitchLineReveal {
    to {
        stroke-dashoffset: 0;
    }
}

/* Pitch dots - always visible, subtle pop animation */
.pitch-accent-svg .pitch-dot {
    opacity: 1;
    transform-origin: center;
    animation: pitchDotReveal 0.3s ease-out forwards;
}

.pitch-accent-svg .pitch-dot:nth-child(1) { animation-delay: 0.1s; }
.pitch-accent-svg .pitch-dot:nth-child(2) { animation-delay: 0.15s; }
.pitch-accent-svg .pitch-dot:nth-child(3) { animation-delay: 0.2s; }
.pitch-accent-svg .pitch-dot:nth-child(4) { animation-delay: 0.25s; }
.pitch-accent-svg .pitch-dot:nth-child(5) { animation-delay: 0.3s; }
.pitch-accent-svg .pitch-dot:nth-child(6) { animation-delay: 0.35s; }
.pitch-accent-svg .pitch-dot:nth-child(7) { animation-delay: 0.4s; }
.pitch-accent-svg .pitch-dot:nth-child(8) { animation-delay: 0.45s; }

@keyframes pitchDotReveal {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* High pitch dot glow */
.pitch-accent-svg .pitch-dot.high {
    filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.6));
}

/* Downstep indicator animation */
.pitch-accent-svg .pitch-downstep {
    opacity: 0;
    animation: pitchDownstepReveal 0.4s ease-out 0.5s forwards;
}

@keyframes pitchDownstepReveal {
    0% {
        opacity: 0;
        transform: translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mora text styling */
.pitch-accent-svg .pitch-mora {
    font-weight: 500;
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LABEL STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.pitch-accent-labels {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.pitch-accent-number {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-weight: 600;
    color: #f97316;
    background: rgba(249, 115, 22, 0.15);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    letter-spacing: 0.02em;
}

.pitch-accent-type {
    color: #a1a1aa;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INLINE VARIANT STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.pitch-inline {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    font-family: 'Noto Sans JP', sans-serif;
}

.pitch-mora-inline {
    position: relative;
    display: inline-block;
    padding: 0 0.1em;
}

.pitch-mora-inline.high {
    color: #22c55e;
}

.pitch-mora-inline.high::before {
    content: '';
    position: absolute;
    top: -0.2em;
    left: 0;
    right: 0;
    height: 2px;
    background: #22c55e;
    border-radius: 1px;
}

.pitch-mora-inline.low {
    color: #a1a1aa;
}

.pitch-mora-inline.downstep::after {
    content: '↓';
    position: absolute;
    right: -0.4em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65em;
    color: #f97316;
    font-weight: bold;
}

.pitch-accent-sup {
    font-size: 0.65em;
    color: #f97316;
    font-weight: 600;
    margin-left: 0.25em;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DETAIL MODAL SECTION
   ═══════════════════════════════════════════════════════════════════════════════ */

.detail-pitch-section {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.06) 0%, rgba(249, 115, 22, 0.04) 100%);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: 0.75rem;
}

.detail-pitch-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.detail-pitch-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #22c55e;
}

.detail-pitch-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #22c55e;
}

/* Badge indicating pitch was derived from TTS audio analysis */
.detail-pitch-derived-badge {
    font-size: 0.5625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a855f7;
    background: rgba(168, 85, 247, 0.15);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.light-mode .detail-pitch-derived-badge,
[data-theme="light"] .detail-pitch-derived-badge {
    color: #9333ea;
    background: rgba(147, 51, 234, 0.12);
}

.detail-pitch-content {
    display: flex;
    justify-content: center;
}

/* Loading state - shown while checking for pitch data */
.detail-pitch-loading {
    opacity: 0.7;
}

.detail-pitch-loading .detail-pitch-icon {
    animation: pitchLoadingPulse 1.5s ease-in-out infinite;
}

.detail-pitch-loading .detail-pitch-title {
    color: var(--text-muted, #a1a1aa);
}

@keyframes pitchLoadingPulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* Found state - fade/slide in animation */
.detail-pitch-found {
    animation: pitchFadeSlideIn 0.3s ease-out;
}

@keyframes pitchFadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade out animation for when no pitch is found */
.detail-pitch-fadeout {
    animation: pitchFadeOut 0.3s ease-out forwards;
}

@keyframes pitchFadeOut {
    from {
        opacity: 0.7;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-4px);
    }
}

/* Reduced motion - disable animations */
@media (prefers-reduced-motion: reduce) {
    .detail-pitch-loading .detail-pitch-icon,
    .detail-pitch-found,
    .detail-pitch-fadeout {
        animation: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   REVIEW SCREEN STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.review-pitch-container {
    display: flex;
    justify-content: center;
    margin: 0.75rem 0;
}

.review-pitch-container .pitch-accent-container {
    transform: scale(0.9);
}

/* Blurred state in review */
.review-pitch-blurred .pitch-accent-container {
    filter: blur(6px);
    opacity: 0.4;
}

.review-pitch-blurred.revealed .pitch-accent-container {
    filter: none;
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .pitch-accent-container {
        padding: 0.5rem 0.75rem;
    }
    
    .pitch-accent-labels {
        font-size: 0.6875rem;
    }
    
    .review-pitch-container .pitch-accent-container {
        transform: scale(0.85);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .pitch-accent-svg .pitch-line,
    .pitch-accent-svg .pitch-dot,
    .pitch-accent-svg .pitch-downstep {
        animation: none;
        opacity: 1;
        stroke-dashoffset: 0;
        transform: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════════ */

.light-mode .pitch-accent-container,
[data-theme="light"] .pitch-accent-container {
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.08) 0%, rgba(234, 88, 12, 0.05) 100%);
    border-color: rgba(22, 163, 74, 0.2);
}

.light-mode .pitch-accent-number,
[data-theme="light"] .pitch-accent-number {
    color: #ea580c;
    background: rgba(234, 88, 12, 0.12);
}

.light-mode .pitch-accent-type,
[data-theme="light"] .pitch-accent-type {
    color: #71717a;
}

.light-mode .pitch-mora-inline.high,
[data-theme="light"] .pitch-mora-inline.high {
    color: #16a34a;
}

.light-mode .pitch-mora-inline.high::before,
[data-theme="light"] .pitch-mora-inline.high::before {
    background: #16a34a;
}

.light-mode .pitch-mora-inline.low,
[data-theme="light"] .pitch-mora-inline.low {
    color: #71717a;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   WORD INFO - Header Pills (in detail modal header bar)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Header vocab pills container */
#modal-vocab-info-pills {
    display: flex;
    align-items: center;
}

#modal-vocab-info-pills .vocab-info-pills {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* Make pills more readable in header context - match frequency badge sizing */
#modal-vocab-info-pills .pos-pill,
#modal-vocab-info-pills .conj-pill,
#modal-vocab-info-pills .katakana-pill {
    font-size: 0.625rem; /* 10px - matches freq badge */
    padding: 0.125rem 0.375rem; /* py-0.5 px-1.5 - matches freq badge */
    line-height: 1.25; /* consistent line-height for alignment */
    opacity: 1;
}

/* Make English labels more visible in header (not faded) */
#modal-vocab-info-pills .pos-pill span.opacity-60,
#modal-vocab-info-pills .conj-pill span.opacity-60 {
    opacity: 0.85;
}

/* POS and Conjugation pill base styles - refined minimal look */
.pos-pill,
.conj-pill {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    opacity: 0.85;
}

.pos-pill:hover,
.conj-pill:hover {
    opacity: 1;
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DETAIL CONJUGATION TABLE
   Collapsible reference table for verb/adjective conjugations in Item Detail
   ═══════════════════════════════════════════════════════════════════════════════ */

.detail-conj-section {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, rgba(52, 211, 153, 0.03) 100%);
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: 0.75rem;
}

.detail-conj-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid rgba(16, 185, 129, 0.12);
}

.detail-conj-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #10B981;
    flex-shrink: 0;
}

.detail-conj-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #10B981;
}

.detail-conj-type {
    font-size: 0.6875rem;
    color: rgba(16, 185, 129, 0.7);
    margin-left: auto;
    font-weight: 500;
}

/* Content area */
.detail-conj-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Form groups */
.detail-conj-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.detail-conj-group-header {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
}

.detail-conj-group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.5);
}

.detail-conj-group-jp {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.35);
}

/* Individual form rows */
.detail-conj-group-rows {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-conj-row {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) 2fr;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    min-height: 2.5rem;
}

.detail-conj-row:hover {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
}

.detail-conj-row--playing {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
}

/* Label column */
.detail-conj-label {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.detail-conj-label-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-conj-pattern {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Noto Sans JP', sans-serif;
}

/* Value column */
.detail-conj-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.detail-conj-form {
    font-size: 1.0625rem;
    font-weight: 500;
    color: #fafafa;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    white-space: nowrap;
}

.detail-conj-reading {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    font-family: 'Noto Sans JP', sans-serif;
}

.detail-conj-tts-icon {
    margin-left: auto;
    width: 1rem;
    height: 1rem;
    color: rgba(16, 185, 129, 0.5);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.detail-conj-tts-icon svg {
    width: 100%;
    height: 100%;
}

.detail-conj-row:hover .detail-conj-tts-icon {
    opacity: 1;
}

/* Expandable "More forms" section - Clean accordion pattern */
.detail-conj-more {
    margin-top: 0.75rem;
}

.detail-conj-more-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(16, 185, 129, 0.8);
    background: transparent;
    border: 1px dashed rgba(16, 185, 129, 0.25);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    list-style: none;
    user-select: none;
}

.detail-conj-more-toggle::-webkit-details-marker {
    display: none;
}

.detail-conj-more-toggle:hover {
    color: #10B981;
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

/* Toggle text between More/Fewer */
.detail-conj-more-text {
    display: inline;
}
.detail-conj-less-text {
    display: none;
}
.detail-conj-more[open] .detail-conj-more-text {
    display: none;
}
.detail-conj-more[open] .detail-conj-less-text {
    display: inline;
}

.detail-conj-chevron {
    width: 0.875rem;
    height: 0.875rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.detail-conj-more[open] .detail-conj-chevron {
    transform: rotate(180deg);
}

.detail-conj-more-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .detail-conj-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
        padding: 0.625rem;
    }
    
    .detail-conj-label {
        flex-direction: row;
        align-items: baseline;
        gap: 0.5rem;
    }
    
    .detail-conj-value {
        padding-left: 0.25rem;
    }
    
    .detail-conj-form {
        font-size: 1.125rem;
    }
    
    .detail-conj-tts-icon {
        opacity: 0.6;
    }
}

/* Light theme overrides */
.light-mode .detail-conj-section,
[data-theme="light"] .detail-conj-section {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(52, 211, 153, 0.04) 100%);
    border-color: rgba(16, 185, 129, 0.2);
}

.light-mode .detail-conj-group-label,
[data-theme="light"] .detail-conj-group-label {
    color: rgba(0, 0, 0, 0.5);
}

.light-mode .detail-conj-group-jp,
[data-theme="light"] .detail-conj-group-jp {
    color: rgba(0, 0, 0, 0.35);
}

.light-mode .detail-conj-row,
[data-theme="light"] .detail-conj-row {
    background: rgba(0, 0, 0, 0.04);
}

.light-mode .detail-conj-row:hover,
[data-theme="light"] .detail-conj-row:hover {
    background: rgba(16, 185, 129, 0.1);
}

.light-mode .detail-conj-label-text,
[data-theme="light"] .detail-conj-label-text {
    color: rgba(0, 0, 0, 0.7);
}

.light-mode .detail-conj-pattern,
[data-theme="light"] .detail-conj-pattern {
    color: rgba(0, 0, 0, 0.4);
}

.light-mode .detail-conj-form,
[data-theme="light"] .detail-conj-form {
    color: #171717;
}

.light-mode .detail-conj-reading,
[data-theme="light"] .detail-conj-reading {
    color: rgba(0, 0, 0, 0.45);
}
