/* style2.css */

/* ---------- DESIGN TOKENS ---------- */

:root {
    --bg-pattern: url("double-bubble-outline.png");
    --color-bg: #f7f7f7;
    --color-text: #555;
    --color-heading-sub: #aeaeae;
    --color-accent: #80d9df;
    --color-button: #e8923a;
    --color-button-secondary: #f2f2f2;
    --color-button-secondary-text: #555;
    --color-square-main: #66bfc5;
    --color-square-dark: #005a60;
    --color-square-light: #cfeaec;
    --radius-lg: 18px;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.08);
}

/* ---------- BASE ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: 'Open Sans', sans-serif;
    color: var(--color-text);
    background: var(--bg-pattern) repeat 0 0;
    background-color: var(--color-bg);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- TRIANGLE BACKGROUND ---------- */

#triangle {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 100vh 100vh;
    border-color: transparent transparent var(--color-accent) transparent;
    z-index: -1;
    transition: opacity 0.5s ease;
}

/* Hide the triangle on smaller screens to avoid overflow */
@media (max-width: 900px) {
    #triangle {
        display: none;
    }
}

/* ---------- LAYOUT WRAPPER ---------- */

#page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px 40px;
}

/* ---------- HEADER ---------- */

#page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #eee;
    margin-bottom: 24px;
    transition: border-color 0.3s ease;
}

.brand h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(2.1rem, 3vw, 3rem);
    font-weight: 800;
    letter-spacing: 1px;
    margin: 4px 0;
    text-transform: uppercase;
}

.brand h1 span {
    color: var(--color-heading-sub);
    display: block;
    font-size: 0.9em;
    font-weight: 300;
    letter-spacing: 1px;
}

.tagline {
    margin: 0;
    font-size: 0.95rem;
    opacity: 0.8;
}

/* When viewport is narrow, stack header */
@media (max-width: 640px) {
    #page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---------- MAIN LAYOUT ---------- */

#crossword-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 24px;
    align-items: flex-start;
}

@media (max-width: 900px) {
    #crossword-layout {
        grid-template-columns: 1fr;
    }
}

/* ---------- GRID PANEL ---------- */

.grid-panel-inner {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-soft);
}

/* Keep crossword container square and responsive */
#crossword {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* modern browsers */
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* Rows are flex so each row fills horizontally */
.crossword-row {
    display: flex;
    flex: 1 1 auto;
}

/* Individual squares – JS will still set colors / attributes */
.square {
    flex: 1 1 auto;
    margin: 2px;
    border-radius: 4px;
    background: var(--color-square-main);
    transition: background 0.15s ease, transform 0.1s ease;
}

.square:hover {
    cursor: pointer;
    transform: translateY(-1px);
}

.square[data-square-color='dark'] {
    background: var(--color-square-dark);
}

.square[data-square-color='light'] {
    background: var(--color-square-light);
}

/* Click feedback animation (optional) */
.bounce {
    animation: bounce 0.3s;
}

@keyframes bounce {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* ---------- SIDE PANEL (CONTROLS) ---------- */

.side-panel-inner {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 18px 18px 22px;
    box-shadow: var(--shadow-soft);
}

#line-adjustment,
.line-adjustment {
    line-height: 1.6;
}

#right-column > p:first-child {
    margin-top: 0;
}

/* Inline examples */
.dark-example {
    color: #d0d0d0;
    font-weight: bold;
    background-color: var(--color-square-dark);
    border-radius: 4px;
    padding: 3px 6px;
}

.light-example {
    color: #000;
    font-weight: bold;
    background-color: var(--color-square-light);
    border-radius: 4px;
    padding: 3px 6px;
}

.neutral-example {
    color: #000;
    font-weight: bold;
    background-color: var(--color-square-main);
    border-radius: 4px;
    padding: 3px 6px;
}

.key-example {
    color: #000;
    font-weight: bold;
    background-color: #d0d0d0;
    border-radius: 2px;
    padding: 2px 6px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

/* ---------- BUTTONS & CONTROLS ---------- */

.button {
    background-color: var(--color-button);
    border: 0;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.button:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Ghost variant for theme toggle */
.button--ghost {
    background-color: transparent;
    color: var(--color-text);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Light secondary button (e.g., Clear Grid) */
.button--secondary {
    background-color: var(--color-button-secondary);
    color: var(--color-button-secondary-text);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 16px 0 10px;
}

.toggle-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 0.9rem;
}

.toggle-container label {
    font-weight: 600;
}

/* On very small screens, stack controls fully */
@media (max-width: 520px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    .toggle-container {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
    }
}

/* Select styling */
select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.9rem;
}

/* ---------- HINT / TEXT BLOCKS ---------- */

.hint-text {
    margin-top: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ---------- MINI-GRIDS / EXAMPLES ---------- */

.examples-section {
    margin-top: 18px;
}

.examples-heading {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
}

.examples-copy {
    margin: 0 0 10px;
    font-size: 0.9rem;
}

#mini-grids-wrapper {
    max-height: 340px;
    overflow: auto;
}

/* Use CSS grid instead of floats */
#mini-grids {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.mini-grid-container {
    width: 100%;
}

.mini-grid {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* ---------- DARK MODE ---------- */

body.dark-mode {
    background-color: #121212;
    background-image: none;
    color: #ddd;
}

body.dark-mode #page-header {
    border-bottom-color: #444;
}

body.dark-mode .brand h1 {
    color: #fff;
}

body.dark-mode .brand h1 span {
    color: #aaa;
}

body.dark-mode .tagline {
    color: #ccc;
}

body.dark-mode .grid-panel-inner,
body.dark-mode .side-panel-inner {
    background-color: #1f1f1f;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
}

body.dark-mode .button--ghost {
    border-color: #555;
    color: #eee;
}

body.dark-mode select {
    background-color: #333;
    color: #fff;
    border-color: #555;
}

body.dark-mode option {
    background-color: #333;
    color: #fff;
}

/* Fade triangle out in dark mode (if still visible on large screens) */
body.dark-mode #triangle {
    opacity: 0;
}

/* Perfect Scrollbar rails (if you use that plugin) */
.ps__rail-x,
.ps__rail-y {
    opacity: 0.6;
}
