/* CSS Variables for Catppuccin Mocha theme - high contrast */
:root {
    --highlight-1: #f38ba8; /* Catppuccin Mocha red */
    --highlight-2: #fab387; /* Catppuccin Mocha peach */
    --highlight-3: #f9e2af; /* Catppuccin Mocha yellow */
    --highlight-4: #a6e3a1; /* Catppuccin Mocha green */
    --highlight-5: #94e2d5; /* Catppuccin Mocha teal */
    --highlight-6: #89b4fa; /* Catppuccin Mocha blue */
    --highlight-7: #b4befe; /* Catppuccin Mocha lavender */
    --highlight-8: #f5c2e7; /* Catppuccin Mocha pink */
    --bg-color: #1e1e2e;    /* Catppuccin Mocha base - dark background */
    --text-color: #cdd6f4;  /* Catppuccin Mocha text - light text */
    --card-bg: #313244;    /* Catppuccin Mocha surface0 - card backgrounds */
    --border-color: #45475a; /* Catppuccin Mocha surface1 - borders */
}

/* Catppuccin Mocha color classes for category backgrounds */
.category-rosewater { background-color: #f5e0dc; color: #1e1e2e; }
.category-flamingo { background-color: #f2cdcd; color: #1e1e2e; }
.category-pink { background-color: #f5c2e7; color: #1e1e2e; }
.category-mauve { background-color: #cba6f7; color: #1e1e2e; }
.category-red { background-color: #f38ba8; color: #1e1e2e; }
.category-maroon { background-color: #eba0ac; color: #1e1e2e; }
.category-peach { background-color: #fab387; color: #1e1e2e; }
.category-yellow { background-color: #f9e2af; color: #1e1e2e; }
.category-green { background-color: #a6e3a1; color: #1e1e2e; }
.category-teal { background-color: #94e2d5; color: #1e1e2e; }
.category-sky { background-color: #89dceb; color: #1e1e2e; }
.category-sapphire { background-color: #74c7ec; color: #1e1e2e; }
.category-blue { background-color: #89b4fa; color: #1e1e2e; }
.category-lavender { background-color: #b4befe; color: #1e1e2e; }

/* Button styles for language toggle and home - Catppuccin Mocha */
#lang-en, #lang-de, #home-btn {
    position: relative;
    z-index: 1000; /* Ensure buttons are above other elements */
    cursor: pointer;
    user-select: none; /* Prevent text selection */
}

#lang-en {
    background-color: #f38ba8; /* Catppuccin Mocha red - active state */
    color: #1e1e2e; /* Dark text for contrast */
    border: 2px solid #f38ba8;
    transition: all 0.3s ease;
}

#lang-en:hover {
    background-color: #eba0ac; /* Lighter red on hover */
    border-color: #eba0ac;
}

#lang-de {
    background-color: #45475a; /* Catppuccin Mocha surface1 - inactive state */
    color: #cdd6f4; /* Light text */
    border: 2px solid #45475a;
    transition: all 0.3s ease;
}

#lang-de:hover {
    background-color: #585b70; /* Lighter surface on hover */
    border-color: #585b70;
}

#lang-es {
    background-color: #45475a; /* Catppuccin Mocha surface1 - inactive state */
    color: #cdd6f4; /* Light text */
    border: 2px solid #45475a;
    transition: all 0.3s ease;
}

#lang-es:hover {
    background-color: #585b70; /* Lighter surface on hover */
    border-color: #585b70;
}

#home-btn {
    background-color: #89b4fa; /* Catppuccin Mocha blue */
    color: #1e1e2e; /* Dark text for contrast */
    border: 2px solid #89b4fa;
    transition: all 0.3s ease;
}

#home-btn:hover {
    background-color: #74c7ec; /* Lighter blue on hover */
    border-color: #74c7ec;
}

#pronunciation-guide-btn {
    background-color: #a6e3a1; /* Catppuccin Mocha green */
    color: #1e1e2e; /* Dark text for contrast */
    border: 2px solid #a6e3a1;
    transition: all 0.3s ease;
}

#pronunciation-guide-btn:hover {
    background-color: #94e2d5; /* Lighter green on hover */
    border-color: #94e2d5;
}

#language-toggle {
    gap: 0;
}

/* Seamless button group styling */
#language-toggle button:not(:last-child) {
    border-right: none;
}

#language-toggle button:not(:first-child) {
    border-left: none;
}

#language-toggle button:first-child {
    border-radius: 0.5rem 0 0 0.5rem;
}

#language-toggle button:last-child {
    border-radius: 0 0.5rem 0.5rem 0;
}

#language-toggle button:not(:first-child):not(:last-child) {
    border-radius: 0;
}

/* Mystical app name styling */
.app-name {
    color: #f38ba8; /* Catppuccin Mocha red */
    font-style: italic;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    font-family: 'Noto Sans JP', serif;
}

/* Base body styling with smooth transitions */
body {
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.6; /* Improved readability for Japanese text */
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Theme overrides for specific elements - Catppuccin Mocha */
/* Note: Category cards use specific color classes, not generic styling */

.sentence-card {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.play-btn {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    cursor: pointer;
}

.play-btn:hover {
    background-color: var(--border-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Category colors - dark text for pastel backgrounds */
.category-rosewater,
.category-flamingo,
.category-pink,
.category-mauve,
.category-red,
.category-maroon,
.category-peach,
.category-yellow,
.category-green,
.category-teal,
.category-sky,
.category-sapphire,
.category-blue,
.category-lavender {
    color: #1e1e2e !important;
}

/* Sentence highlights - subtle highlighting */
.sentence-highlight {
    background-color: rgba(137, 220, 235, 0.25); /* Light sky blue from Catppuccin */
    color: var(--text-color);
}

/* Category title and description */
#category-title,
#category-description {
    color: var(--text-color) !important;
}

/* Category card hover effects */
.category-card {
    transition: transform 0.3s, box-shadow 0.3s;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Sentence highlight styling */
.sentence-highlight {
    background-color: rgba(137, 220, 235, 0.25); /* Light sky blue from Catppuccin */
    color: #1e1e2e; /* Dark text for contrast */
    font-weight: bold; /* Bold font for emphasis */
    padding: 2px 4px;
    border-radius: 3px;
}

/* Karaoke active word styling - using Catppuccin Mocha colors */
.karaoke-active {
    background-color: #f38ba8; /* Catppuccin Mocha red */
    color: #1e1e2e; /* Dark text for readability */
    font-weight: normal; /* Normal weight */
    padding: 2px 4px; /* Standard padding */
    border-radius: 3px; /* Subtle rounding */
    transition: background-color 0.2s ease; /* Smooth color transition */
}

/* Word highlight base styling */
.word-highlight {
    display: inline-block;
    padding: 2px 4px;
    border-radius: 3px;
    margin: 0 2px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.word-highlight:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Highlight color classes using CSS variables */
.highlight-1 { background-color: var(--highlight-1); color: #1e1e2e !important; }
.highlight-2 { background-color: var(--highlight-2); color: #1e1e2e !important; }
.highlight-3 { background-color: var(--highlight-3); color: #1e1e2e !important; }
.highlight-4 { background-color: var(--highlight-4); color: #1e1e2e !important; }
.highlight-5 { background-color: var(--highlight-5); color: #1e1e2e !important; }
.highlight-6 { background-color: var(--highlight-6); color: #1e1e2e !important; }
.highlight-7 { background-color: var(--highlight-7); color: #1e1e2e !important; }
.highlight-8 { background-color: var(--highlight-8); color: #1e1e2e !important; }

/* Progress bar container styling */
.progress-bar {
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

/* Progress fill bar styling */
.progress-fill {
    height: 100%;
    background-color: #f38ba8; /* Catppuccin Mocha red */
    width: 0%;
    transition: width 0.3s;
}

/* Mobile responsiveness optimizations */
@media (max-width: 768px) {
    /* Increase base font size for better readability on small screens */
    body {
        font-size: 16px;
    }

    /* Adjust heading sizes for mobile */
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Make buttons touch-friendly with minimum 44px height and width */
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        font-size: 16px;
    }

    /* Adjust container padding for mobile */
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Increase spacing between elements for better touch interaction */
    .category-card {
        margin-bottom: 16px;
    }

    /* Disable hover effects on touch devices, use active state instead */
    .category-card:hover {
        transform: none;
        box-shadow: none;
    }

    .category-card:active {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    }

    .word-highlight:hover {
        transform: none;
        box-shadow: none;
    }

    .word-highlight:active {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .play-btn:hover {
        transform: none;
        box-shadow: none;
    }

    .play-btn:active {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Ensure word highlights are readable on mobile */
    .word-highlight {
        padding: 4px 6px;
        margin: 2px;
        font-size: 16px;
    }

    /* Adjust progress bar height for mobile */
    .progress-bar {
        height: 6px;
    }

    /* Increase sentence highlight padding for better visibility */
    .sentence-highlight {
        padding: 4px 6px;
    }

    /* Ensure karaoke active word is prominent */
    .karaoke-active {
        font-size: 18px;
        padding: 4px 6px;
    }
}


/* Modal styling for pronunciation guide and romanji breakdown */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Romanji text styling */
.romanji-text {
    transition: color 0.3s ease;
}

.romanji-text:hover {
    color: #f38ba8; /* Catppuccin red on hover */
}

/* Custom descriptive classes combining Tailwind utilities */
.main-container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.app-title {
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 700;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.toggle-btn {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.15s ease-in-out;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .categories-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .categories-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.hidden-screen {
  display: none;
}

.back-btn-container {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.icon-margin {
  margin-right: 0.5rem;
}

.category-title {
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #4b5563;
}

.category-desc {
  color: #4b5563;
  margin-bottom: 1rem;
}

/* New descriptive classes for Tailwind utilities */
.section-margin-bottom { margin-bottom: 1rem; }
.element-margin-bottom { margin-bottom: 0.5rem; }
.paragraph-margin-bottom { margin-bottom: 0.75rem; }
.small-margin-bottom { margin-bottom: 0.25rem; }
.large-margin-bottom { margin-bottom: 1.5rem; }
.small-margin-top { margin-top: 0.5rem; }
.medium-margin-top { margin-top: 1rem; }
.small-padding { padding: 0.5rem; }
.medium-padding { padding: 0.75rem; }
.large-padding { padding: 1rem; }
.extra-large-padding { padding: 1.5rem; }
.horizontal-small-padding { padding-left: 0.75rem; padding-right: 0.75rem; }
.horizontal-medium-padding { padding-left: 1rem; padding-right: 1rem; }
.vertical-tiny-padding { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.vertical-small-padding { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.vertical-small-gap > * + * { margin-top: 0.5rem; }
.grid-medium-gap { gap: 1rem; }
.small-text { font-size: 0.875rem; line-height: 1.25rem; }
.extra-small-text { font-size: 0.75rem; line-height: 1rem; }
.large-text { font-size: 1.125rem; line-height: 1.75rem; }
.extra-large-text { font-size: 1.25rem; line-height: 1.75rem; }
.double-large-text { font-size: 1.5rem; line-height: 2rem; }
.bold-text { font-weight: 700; }
.semi-bold-text { font-weight: 600; }
.flex-container { display: flex; }
.flex-column { flex-direction: column; }
.items-flex-start { align-items: flex-start; }
.items-center { align-items: center; }
.justify-space-between { justify-content: space-between; }
.justify-flex-end { justify-content: flex-end; }
.grid-container { display: grid; }
.single-column-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.red-background { background-color: #ef4444; }
.blue-background { background-color: #3b82f6; }
.gray-background { background-color: #6b7280; }
.white-background { background-color: #ffffff; color: #1e1e2e !important; }
.light-gray-background { background-color: #f3f4f6; color: #1e1e2e !important; }
.light-blue-background { background-color: #eff6ff; color: #1e1e2e !important; }
.light-red-background { background-color: #fef2f2; color: #1e1e2e !important; }
.light-purple-background { background-color: #faf5ff; color: #1e1e2e !important; }
.light-green-background { background-color: #f0fdf4; color: #1e1e2e !important; }
.light-orange-background { background-color: #fff7ed; color: #1e1e2e !important; }
.light-yellow-background { background-color: #fefce8; color: #1e1e2e !important; }
.white-text { color: #ffffff; }
.blue-text { color: #2563eb; }
.small-rounded { border-radius: 0.25rem; }
.medium-rounded { border-radius: 0.5rem; }
.full-rounded { border-radius: 9999px; }
.bordered { border-width: 1px; }
.full-width { width: 100%; }
.medium-max-width { max-width: 28rem; }
.large-max-width { max-width: 42rem; }
.medium-max-height { max-height: 24rem; }
.scrollable-vertical { overflow-y: auto; }
.block-element { display: block; }
@media (min-width: 768px) {
  .medium-two-column-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .medium-three-column-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Content Block Styling - Modular Lego-like Components */

/* Base content block styles */
.content-block {
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    position: relative;
}

/* Cultural Notes Block - Dark background for better contrast */
.cultural-notes-block {
    background-color: rgba(49, 50, 68, 0.9); /* Dark surface with transparency */
    border-left: 4px solid #f38ba8; /* Catppuccin red accent */
    color: #cdd6f4; /* Light text for dark background */
    border: 1px solid rgba(243, 139, 168, 0.3); /* Subtle red border */
}

.cultural-notes-block::before {
    content: "文化";
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background-color: #f38ba8;
    color: #1e1e2e; /* Dark text on red background */
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Pronunciation Block - Dark background for better contrast */
.pronunciation-block {
    background-color: rgba(49, 50, 68, 0.9); /* Dark surface with transparency */
    border-left: 4px solid #89b4fa; /* Catppuccin blue accent */
    color: #cdd6f4; /* Light text for dark background */
    border: 1px solid rgba(137, 180, 250, 0.3); /* Subtle blue border */
    font-size: 1em;
}

.content-block.pronunciation-block {
    font-size: calc(1em + 2px);
}

.pronunciation-block::before {
    content: "発音";
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background-color: #89b4fa;
    color: #1e1e2e; /* Dark text on blue background */
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Word Highlights Block - Dark background for better contrast */
.word-highlights-block {
    background-color: rgba(49, 50, 68, 0.9); /* Dark surface with transparency */
    border-left: 4px solid #fab387; /* Catppuccin peach accent */
    color: #cdd6f4; /* Light text for dark background */
    border: 1px solid rgba(250, 179, 135, 0.3); /* Subtle peach border */
}

.word-highlights-block::before {
    content: "単語";
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background-color: #fab387;
    color: #1e1e2e; /* Dark text on peach background */
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Japanese Text Block - Dark background for better contrast */
.japanese-text-block {
    background-color: rgba(49, 50, 68, 0.9); /* Dark surface with transparency */
    border-left: 4px solid #f5c2e7; /* Catppuccin pink accent */
    color: #cdd6f4; /* Light text for dark background */
    border: 1px solid rgba(245, 194, 231, 0.3); /* Subtle pink border */
}

.japanese-text-block::before {
    content: "日本語";
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background-color: #f5c2e7;
    color: #1e1e2e; /* Dark text on pink background */
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Target Language Block - Dark background for better contrast */
.target-language-block {
    background-color: rgba(49, 50, 68, 0.9); /* Dark surface with transparency */
    border-left: 4px solid #a6e3a1; /* Catppuccin green accent */
    color: #cdd6f4; /* Light text for dark background */
    border: 1px solid rgba(166, 227, 161, 0.3); /* Subtle green border */
}

.target-language-block::before {
    content: "学習言語";
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background-color: #a6e3a1;
    color: #1e1e2e; /* Dark text on green background */
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Progress Block - Dark background for better contrast */
.progress-block {
    background-color: rgba(49, 50, 68, 0.9); /* Dark surface with transparency */
    border-left: 4px solid #b4befe; /* Catppuccin lavender accent */
    color: #cdd6f4; /* Light text for dark background */
    border: 1px solid rgba(180, 190, 254, 0.3); /* Subtle lavender border */
}

.progress-block::before {
    content: "進捗";
    position: absolute;
    top: -0.5rem;
    right: 0.5rem;
    background-color: #b4befe;
    color: #1e1e2e; /* Dark text on lavender background */
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Hover functionality for data-content-block */
.data-content-block .cultural-notes-block,
.data-content-block .pronunciation-block {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.data-content-block:hover .cultural-notes-block,
.data-content-block:hover .pronunciation-block {
    opacity: 1;
}

/* Furigana styling for pronunciation help - aids reading romanji by showing kana pronunciation */
.furigana {
    font-size: 1em; /* Same size as normal text */
    color: var(--highlight-6); /* Catppuccin blue for kana */
    font-weight: normal;
    line-height: 1;
    vertical-align: super;
    margin-left: -0.2em;
    margin-right: -0.2em;
    opacity: 1; /* Always visible and full opacity */
}

/* Ruby text container adjustments */
ruby {
    ruby-position: over;
    ruby-align: center;
    font-size: inherit; /* Inherit parent font size */
}

/* Ensure furigana displays properly on mobile */
@media (max-width: 768px) {
    .furigana {
        font-size: 1em; /* Maintain full size on mobile */
    }

    ruby {
        font-size: 16px; /* Ensure base text remains readable */
    }
}

/* Hover effect for furigana (optional enhancement) */
ruby:hover .furigana {
    color: var(--highlight-1); /* Red highlight on hover */
    font-size: 1em; /* Maintain full size on hover */
    transition: color 0.2s ease;
}