/*
 * File: style.css
 * Description: Contains all CSS styles for the BIG TEXT mobile application.
 * Designed for responsiveness, accessibility, and visual appeal.
 * Focuses on seamless background, minimalist buttons, and scrollable edit interface.
 */

/* --------------------------- Global Styles ---------------------------------- */
:root {
    /* Define some primary colors for easy modification */
    --primary-bg-dark: #191970; /* Midnight Blue for dark mode, consistent across app */
    --secondary-bg-dark: #2a2a80; /* Slightly lighter blue for edit panel */
    --button-bg-subtle: rgba(0, 0, 0, 0.1); /* Very subtle background for buttons */
    --button-hover-bg-subtle: rgba(0, 0, 0, 0.3); /* Slightly more visible on hover */
    --text-color-light: #FFFFFF;
    --text-color-dark: #333333;
    --border-radius: 8px; /* Slightly smaller rounded corners for buttons */
    --shadow-color: rgba(0, 0, 0, 0.4);
    --neon-green: #39FF14;
    --gold-yellow: #FFD700;
    --bright-orange: #FFA500;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%; /* Use min-height to allow content to push height */
    display: flex;
    flex-direction: column; /* Allow content and controls to stack */
    justify-content: flex-start; /* Start content from top */
    align-items: center;
    font-family: 'Noto Sans', sans-serif; /* Aptos fallback with Noto Sans */
    background-color: var(--primary-bg-dark); /* Consistent default background */
    color: var(--text-color-light);
    box-sizing: border-box;
    overflow-y: auto; /* Allow vertical scrolling on the entire page if content overflows */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
}

/* Ensure images and media are responsive */
img, video {
    max-width: 100%;
    height: auto;
}

/* Accessible focus states */
a:focus, button:focus, input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--button-hover-bg-dark); /* A more subtle focus */
    outline-offset: 1px; /* Smaller offset */
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2); /* Soft white glow on focus */
}

/* --------------------------- Typography ------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Gabriela', serif;
    color: inherit; /* Inherit color from parent for theme consistency */
    text-shadow: 1px 1px 2px var(--shadow-color); /* Lighter shadow for headers */
    margin-top: 0;
    margin-bottom: 0.5em;
}

h2 {
    font-size: 1.8em;
    text-align: center;
    margin-bottom: 1em;
    color: var(--text-color-light); /* Default to light for dark backgrounds */
}

p {
    line-height: 1.6;
}

/* --------------------------- Container Layout ------------------------------- */
.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 96%; /* Use most of the available width on mobile */
    max-width: 600px; /* Max width for larger screens */
    flex-grow: 1; /* Allow container to grow and fill available space */
    margin: 10px auto; /* Auto margin for horizontal centering, smaller top/bottom margin */
    background-color: transparent; /* Make container background transparent to show body background */
    border-radius: var(--border-radius);
    box-sizing: border-box;
    padding: 10px; /* Small inner padding */
    position: relative; /* For absolute positioning of children if needed, though not strictly for this current setup */
    min-height: calc(100% - 80px); /* Adjust based on control panel height to ensure it fits */
}

/* --------------------------- Big Text Display ------------------------------- */
.big-text-display {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    font-weight: bold;
    line-height: 1;
    flex-grow: 1; /* Allows the text display to take up available space */
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
    text-shadow: 3px 3px 6px var(--shadow-color); /* Slightly lighter shadow for text */
    min-width: 0;
    min-height: 0;
    /* Ensure text area is transparent to show body background */
    background-color: transparent;
}

/* --------------------------- Controls & Buttons ----------------------------- */
.controls {
    position: fixed; /* Fixes buttons to the bottom of the viewport */
    bottom: 0; /* Aligns to the bottom edge */
    left: 0;
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around; /* Distribute space evenly among buttons */
    align-items: center;
    gap: 0; /* No gap between buttons for maximum compactness */
    padding: 5px 0; /* Minimal padding */
    background-color: rgba(0, 0, 0, 0.1); /* Very subtle background for the control bar */
    border-top-left-radius: var(--border-radius); /* Rounded top corners for the bar */
    border-top-right-radius: var(--border-radius);
    box-sizing: border-box;
    z-index: 100; /* Ensure buttons are above other content */
    backdrop-filter: blur(3px); /* Soft blur effect behind buttons */
    -webkit-backdrop-filter: blur(3px); /* For Safari */
}

.button-form {
    display: contents; /* Allows form elements to be direct children of .controls for flex layout */
}

/* Base style for icon buttons - minimal visibility */
.icon-button {
    background-color: transparent; /* No background */
    color: rgba(255, 255, 255, 0.4); /* Barely visible white color */
    border: none; /* No border */
    padding: 8px 12px; /* Small padding */
    font-size: 1.8em; /* Size of emoji/icon */
    line-height: 1; /* Compact line height */
    font-weight: normal; /* No bold for simple icons */
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.1s ease;
    box-shadow: none; /* No shadow */
    flex-grow: 0; /* Do not grow */
    flex-shrink: 0; /* Do not shrink unnecessarily */
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    color: rgba(255, 255, 255, 0.8); /* More visible on hover */
    background-color: rgba(255, 255, 255, 0.05); /* Slight background tint on hover */
    transform: scale(1.05); /* Slightly pop out */
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2); /* Soft glow */
}

.icon-button:active {
    transform: scale(0.95); /* Slight press effect */
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

/* Primary button style (for Save button in edit mode) */
.button.primary-button {
    background-color: #28a745; /* Green for save/submit */
    color: white;
    padding: 12px 20px; /* Standard button size */
    font-size: 1.1em;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.button.primary-button:hover {
    background-color: #218838;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}


/* --------------------------- Edit Mode Panel -------------------------------- */
.edit-mode-panel {
    background-color: var(--secondary-bg-dark);
    padding: 20px;
    border-radius: var(--border-radius);
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    flex-grow: 1; /* Allow panel to grow and take available space */
    /* crucial for scrolling */
    max-height: 100%; /* Constrain height to parent */
    overflow-y: auto; /* Allow vertical scrolling within the panel */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
    padding-bottom: 80px; /* Add padding at bottom to prevent controls from covering content */
}

.edit-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
    gap: 15px;
    align-items: center;
}

.text-input {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    border: 2px solid var(--button-bg-dark); /* Keeping previous button color for input border */
    border-radius: var(--border-radius);
    background-color: #333;
    color: var(--text-color-light);
    resize: none;
    height: 100px;
    box-sizing: border-box;
}

.text-input:focus {
    border-color: var(--button-hover-bg-dark);
    box-shadow: 0 0 8px rgba(95, 158, 160, 0.5);
}

.char-count {
    font-size: 0.9em;
    color: #bbb;
    align-self: flex-end;
}

/* --------------------------- Theme Selection -------------------------------- */
h3 {
    text-align: center;
    width: 100%;
}

.theme-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Smaller min-width for theme options */
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px; /* Smaller padding */
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-option input[type="radio"]:checked + .theme-name {
    font-weight: bold;
    text-decoration: underline;
}

.theme-option.selected {
    border-color: var(--button-hover-bg-dark); /* Use a more prominent border to indicate selection */
    box-shadow: 0 0 8px var(--button-hover-bg-dark);
}

.theme-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.theme-name {
    font-size: 0.85em; /* Slightly smaller font for theme names */
    text-align: center;
    margin-top: 5px;
}

/* --------------------------- Theme Specific Styles -------------------------- */
/* Apply theme background to body for consistency */
.theme-neon-on-dark {
    background-color: #1A1A1A; /* Body background */
    color: var(--neon-green);
}
.theme-neon-on-dark .big-text-display {
    text-shadow: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green);
}
.theme-neon-on-dark .edit-mode-panel {
    background-color: #2A2A2A; /* Slightly lighter background for edit panel */
}
.theme-neon-on-dark .text-input {
    border-color: var(--neon-green);
    box-shadow: 0 0 5px var(--neon-green);
}
.theme-neon-on-dark h2, .theme-neon-on-dark h3 {
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
}

.theme-yellow-on-dark {
    background-color: #2A0000;
    color: var(--gold-yellow);
}
.theme-yellow-on-dark .big-text-display {
    text-shadow: 2px 2px 4px rgba(255, 215, 0, 0.5);
}
.theme-yellow-on-dark .edit-mode-panel {
    background-color: #3A0000;
}
.theme-yellow-on-dark .text-input {
    border-color: var(--gold-yellow);
}
.theme-yellow-on-dark h2, .theme-yellow-on-dark h3 {
    color: var(--gold-yellow);
}

.theme-orange-on-dark {
    background-color: #1A0D00;
    color: var(--bright-orange);
}
.theme-orange-on-dark .big-text-display {
    text-shadow: 2px 2px 4px rgba(255, 165, 0, 0.5);
}
.theme-orange-on-dark .edit-mode-panel {
    background-color: #2A1D00;
}
.theme-orange-on-dark .text-input {
    border-color: var(--bright-orange);
}
.theme-orange-on-dark h2, .theme-orange-on-dark h3 {
    color: var(--bright-orange);
}

/* Ensure buttons in themed context maintain their subtle nature */
.theme-neon-on-dark .icon-button:hover {
    color: var(--neon-green);
    background-color: rgba(57, 255, 20, 0.1);
}
.theme-yellow-on-dark .icon-button:hover {
    color: var(--gold-yellow);
    background-color: rgba(255, 215, 0, 0.1);
}
.theme-orange-on-dark .icon-button:hover {
    color: var(--bright-orange);
    background-color: rgba(255, 165, 0, 0.1);
}


/* --------------------------- Utility Classes -------------------------------- */
.rounded-corners {
    border-radius: var(--border-radius);
}

/* Debug Mode Indicator */
.debug-indicator {
    position: fixed;
    bottom: 50px; /* Adjust to not overlap with controls */
    left: 50%;
    transform: translateX(-50%);
    background-color: red;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    z-index: 1000;
}

/* --------------------------- Media Queries for Responsiveness --------------- */
/* Landscape orientation on small devices (e.g., phones) */
@media screen and (orientation: landscape) and (max-height: 500px) {
    body {
        flex-direction: row; /* Arrange main sections side-by-side */
        justify-content: space-between;
        align-items: stretch;
    }

    .container {
        flex-basis: 70%; /* Give more space to main content */
        height: auto; /* Allow height to adjust */
        margin: 10px;
        padding: 5px;
        min-height: calc(100% - 20px); /* Fill available height minus margins */
    }

    .big-text-display {
        /* No change needed here, flex-grow handles it */
    }

    .edit-mode-panel {
        padding-bottom: 20px; /* Reduce bottom padding in landscape edit mode */
    }

    .controls {
        position: static; /* Let controls flow naturally in the layout */
        flex-direction: column; /* Stack buttons vertically */
        justify-content: space-around;
        flex-basis: 25%; /* Take up remaining space */
        padding: 5px;
        margin: 10px; /* Small margin around controls */
        height: auto; /* Adjust height based on content */
        border-radius: var(--border-radius);
        background-color: var(--secondary-bg-dark); /* Give it a background similar to edit panel */
        backdrop-filter: none; /* No blur needed if not floating */
        -webkit-backdrop-filter: none;
    }

    .icon-button {
        padding: 10px; /* Slightly larger padding for vertical buttons */
        font-size: 2em; /* Keep icons large */
    }
}

/* Tablets and larger phones in portrait */
@media (min-width: 600px) {
    .container {
        padding: 20px;
    }

    .edit-mode-panel {
        padding: 30px;
    }

    .text-input {
        font-size: 1.4em;
        height: 120px;
    }

    .theme-option {
        padding: 20px;
    }

    h2 {
        font-size: 2em;
    }

    .icon-button {
        padding: 10px 15px; /* Slightly larger clickable area */
        font-size: 2em; /* Keep icons large */
    }
}

/* Large screens (e.g., desktops, large tablets) */
@media (min-width: 768px) {
    .container {
        max-width: 800px;
        max-height: 90%;
        margin: 5% auto; /* Center with auto margin */
    }

    .edit-mode-panel {
        max-width: 600px;
    }

    .text-input {
        height: 150px;
    }
}

/* style.css */