/* ============================================
   CROSSWORD BUILDER STYLES
   ============================================ */

.cw-builder-container {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
    margin-bottom: 4rem;
}

/* LEFT PANEL (Settings & Grid) */
.cw-left-panel {
    flex: 1.2;
    min-width: 0;
}

.cw-settings-box {
    background: var(--color-surface-container-low);
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.cw-decorative-bg {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 6rem;
    font-family: var(--font-headline);
    color: var(--color-outline-variant);
    opacity: 0.1;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

.cw-settings-row {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: center;
}

.cw-setting label,
.cw-actions-row label {
    display: block;
    font-family: var(--font-label);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-on-surface-variant);
    margin-bottom: 0.5rem;
}

.cw-setting select {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-outline-variant);
    font-family: var(--font-headline);
    font-size: 1.125rem;
    padding: 0.25rem 0;
    color: var(--color-on-surface);
    outline: none;
    cursor: pointer;
}

.cw-setting select:focus {
    border-bottom-color: var(--color-primary);
}

.cw-symmetry-toggles {
    display: flex;
    gap: 0.5rem;
}

.cw-sym-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-container-highest);
    color: var(--color-on-surface-variant);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
}

.cw-sym-btn .material-symbols-outlined {
    font-size: 1rem;
}

.cw-sym-btn.active {
    background: var(--color-surface-dim);
    color: var(--color-on-surface);
    opacity: 1;
}

.cw-actions-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

.cw-quick-actions button {
    background: none;
    border: none;
    color: var(--color-on-surface-variant);
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

.cw-quick-actions button:hover {
    color: var(--color-error);
}

.cw-grid-wrapper {
    background: #fff;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.crossword-grid {
    display: grid;
    /* Grid columns set via JS */
    border: 1.5px solid var(--color-on-surface);
}

.crossword-cell {
    aspect-ratio: 1/1;
    border: 0.5px solid var(--color-outline-variant);
    position: relative;
    cursor: pointer;
    background: #fff;
    transition: background-color 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crossword-cell:hover {
    background: var(--color-surface-container-high);
}

.crossword-cell.cw-black {
    background-color: var(--color-on-surface);
    border-color: var(--color-on-surface);
}

.crossword-cell.cw-active {
    background-color: var(--color-surface-dim);
}

.crossword-cell .cw-num {
    position: absolute;
    top: 2px;
    left: 2px;
    font-family: var(--font-label);
    font-size: 0.5rem;
    color: var(--color-on-surface);
    line-height: 1;
    pointer-events: none;
}

.crossword-cell input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-family: var(--font-headline);
    font-size: 1.125rem;
    text-transform: uppercase;
    color: var(--color-tertiary);
    outline: none;
    padding: 0;
    pointer-events: none; /* Let the cell handle clicks */
}

.cw-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.cw-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-label);
    font-size: 0.625rem;
    color: var(--color-on-surface-variant);
    font-style: italic;
}

.cw-legend-box {
    width: 0.75rem;
    height: 0.75rem;
    display: inline-block;
}

.cw-legend-box.white { border: 1px solid var(--color-outline-variant); background: #fff; }
.cw-legend-box.black { background: var(--color-on-surface); }
.cw-legend-box.blue { background: var(--color-surface-dim); }

/* RIGHT PANEL (Clues) */
.cw-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.cw-clues-section {
    padding-left: 1.5rem;
}

.cw-clues-section.orizzontali {
    border-left: 4px solid var(--color-surface-dim);
}

.cw-clues-section.verticali {
    border-left: 4px solid var(--color-surface-container-highest);
}

.cw-clues-section h3 {
    font-family: var(--font-headline);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--color-on-surface);
    letter-spacing: -0.01em;
}

.cw-clues-list {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Scrollbar per indizi */
.cw-clues-list::-webkit-scrollbar {
    width: 6px;
}
.cw-clues-list::-webkit-scrollbar-track {
    background: transparent;
}
.cw-clues-list::-webkit-scrollbar-thumb {
    background: var(--color-outline-variant);
}

.cw-clue-item {
    border-bottom: 1px solid var(--color-outline-variant);
    padding-bottom: 0.5rem;
}

.cw-clue-item.empty-clue {
    opacity: 0.5;
}

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

.cw-clue-header span {
    font-family: var(--font-label);
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--color-tertiary);
}

.empty-clue .cw-clue-header span {
    color: var(--color-on-surface-variant);
}

.cw-clue-item input {
    width: 100%;
    background: transparent;
    border: none;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-style: italic;
    color: var(--color-on-surface);
    outline: none;
    padding: 0;
}

.cw-clue-item input::placeholder {
    color: var(--color-outline-variant);
}

/* FOOTER */
.cw-footer {
    position: sticky;
    bottom: 0;
    background: rgba(250, 249, 245, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1rem 2rem;
    border-top: 1px solid var(--color-outline-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 -3rem -4rem -3rem; /* Compensate main padding */
}

.cw-stats {
    display: flex;
    gap: 3rem;
}

.cw-stat-block label {
    display: block;
    font-family: var(--font-label);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-on-surface-variant);
    margin-bottom: 0.25rem;
}

.cw-stat-block span {
    font-family: var(--font-headline);
    font-size: 1.25rem;
    color: var(--color-on-surface);
}

.cw-save-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cw-save-status {
    font-family: var(--font-label);
    font-size: 0.6875rem;
    color: var(--color-on-surface-variant);
}

.cw-title-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-outline-variant);
    font-family: var(--font-headline);
    font-size: 1.125rem;
    padding: 0.25rem 0;
    color: var(--color-on-surface);
    outline: none;
    width: 200px;
}
.cw-title-input:focus { border-bottom-color: var(--color-primary); }

/* ============================================
   GIOCHI LANDING CARD (Dashboard Gray)
   ============================================ */

.dash-game-card {
    display: flex;
    border-radius: 12px;
    background: var(--color-surface-container-low);
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    border: 1px solid var(--color-outline-variant);
    position: relative;
    cursor: pointer;
}

.dash-game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(47, 52, 46, 0.08);
    background: var(--color-background);
}

.dash-primary-game {
    grid-template-columns: 1fr 1fr;
    display: grid;
    min-height: 280px;
}

.dash-game-card-content {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
}

.dash-category-tag {
    font-family: var(--font-label);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-primary);
    margin-bottom: 1rem;
    display: inline-block;
}

.dash-headline-lg {
    font-family: var(--font-headline);
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--color-on-background);
}

.dash-body-md {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-on-surface-variant);
}

.dash-btn-giochi {
    display: inline-block;
    font-family: var(--font-label);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background-color: var(--color-on-surface);
    color: var(--color-background);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    margin-top: 2rem;
    align-self: flex-start;
}

.dash-game-card:hover .dash-btn-giochi {
    background-color: var(--color-primary);
    transform: scale(1.02);
}

.dash-game-card-visual {
    background-color: var(--color-surface-container-highest);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.dash-cruciverba-preview {
    width: 200px;
    height: 160px;
    transform: rotate(5deg);
    transition: transform 0.5s ease;
}

.dash-game-card:hover .dash-cruciverba-preview {
    transform: rotate(0deg) scale(1.05);
}

.dash-preview-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    background-color: var(--color-outline);
    padding: 3px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(47, 52, 46, 0.1);
}

.dash-preview-grid .c {
    background: #fff;
    aspect-ratio: 1;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-label);
    font-weight: 700;
    color: var(--color-on-background);
    font-size: 1rem;
}

.dash-preview-grid .c.black {
    background: var(--color-on-background);
}

@keyframes dashTypeLetter {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.dash-preview-grid .c.txt {
    animation: dashTypeLetter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

.dash-preview-grid .c.txt:nth-child(2) { animation-delay: 0.1s; }
.dash-preview-grid .c.txt:nth-child(3) { animation-delay: 0.2s; }
.dash-preview-grid .c.txt:nth-child(4) { animation-delay: 0.3s; }
.dash-preview-grid .c.txt:nth-child(5) { animation-delay: 0.4s; }
.dash-preview-grid .c.txt:nth-child(6) { animation-delay: 0.5s; }
.dash-preview-grid .c.txt:nth-child(8) { animation-delay: 0.6s; }
.dash-preview-grid .c.txt:nth-child(10) { animation-delay: 0.7s; }
