/* CSS specific to the puzzle page(s) - make sure we have the main one included */
@import './style.css';

:root {
    --grid-cell-gap: 6px;
    --grid-cell-font-size: 1.5em;
    --grid-cell-font-family: sans-serif;
    --grid-cell-font-weight: bold;
}

:root,
[data-theme="light"] {
    --grid-cell-background: #f4f4f4;
    --grid-cell-border: #ccc;
    --grid-cell-completed-background: #cccccc;
    --grid-cell-completed-color: #bd6ed8;
    --grid-cell-completed-zerozero: #888;
    --grid-cell-selected-background: #eabb09;
    --grid-cell-selected-color: #333;
    --grid-cell-tile-background: #f8d347;
    --grid-cell-tile-color: #2c3e50;
    --score-flash-color: #e03030;
    --trail-color: #800000;
    --trail-transparency: 0.2;
    --word-starts-color: #6dac63;
    --word-contains-color: #666;
}

[data-theme="dark"] {
    --grid-cell-background: #343434;
    --grid-cell-border: #646464;
    --grid-cell-completed-background: #343434;
    --grid-cell-completed-color: #bd6ed8;
    --grid-cell-completed-zerozero: #646464;
    --grid-cell-selected-background: #eabb09;
    --grid-cell-selected-color: #333;
    --grid-cell-tile-background: #f8d347;
    --grid-cell-tile-color: #2c3e50;
    --score-flash-color: #e37a4d;
    --trail-color: #400000;
    --trail-transparency: 0.3;
    --word-starts-color: #79a346;
    --word-contains-color: #666;
}

/* Define a wobble animation */
@keyframes wobble {
    0% { transform: translateX(0%); }
    10% { transform: translateX(-10%) rotate(-2deg); }
    20% { transform: translateX(10%) rotate(-2deg); }
    30% { transform: translateX(-10%) rotate(2deg); }
    40% { transform: translateX(10%) rotate(2deg); }
    50% { transform: translateX(-10%) rotate(-2deg); }
    60% { transform: translateX(10%) rotate(-2deg); }
    70% { transform: translateX(-10%) rotate(2deg); }
    80% { transform: translateX(10%) rotate(2deg); }
    90% { transform: translateX(-10%) rotate(-2deg); }
    100% { transform: translateX(0%); }
}

/* Add a wobble animation class */
.wobble {
    animation-name: wobble;
    animation-duration: 0.5s;
    animation-timing-function: ease-in-out;
}

/* Outcome message */

#outcome-message {
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 10px;
    box-sizing: border-box;
    font-size: 16px;
    transition: transform 0.3s ease-in-out;
}

#outcome-message.styledText {
    font-size: 26px;
    font-weight: bold;
    border: 1px solid var(--grid-cell-border);
    border-radius: 8px;
    background-color: var(--grid-cell-background);
    padding: 0px 10px 0px 10px;
}

#found-order-selection {
    height: 30px;
}

/* Trail canvas */
#trail-canvas {
    background: transparent
}

.no-words-message {
    font-style: italic;
}

.found-word-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100px, 100%), 1fr));
    gap: 6px;
    padding-bottom: 20px;
}

.found-word-list-leader {
    font-weight: bold;
    padding-top: 0px;
}

/* Container for the main content */
.game-container {
    display: flex;
    flex-direction: row;
    padding-top: 20px;
    gap: 20px;
    box-sizing: border-box;

    flex-wrap: wrap;
}

/* Specialised container for title and word counter */

.h3-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.h3-container h3 {
    margin: 0;
    text-align: left;
    flex-shrink: 0;
}

.h3-container .right-aligned {
    font-size: 1.5em;
    margin-left: auto;
    transition: transform 0.3s ease, color 0.3s ease;
}

/* Flash animation */
.flash {
    transition: transform 0.3s ease, color 0.3s ease;
    transform: scale(2.5);
    color: var(--score-flash-color);
}

/* Flash animation */
.flare {
    transition: transform 0.3s ease, color 0.3s ease;
    transform: scale(1.1);
    color: var(--score-flash-color);
}

/* Flash animation */
.spin {
    transition: transform 0.3s ease, color 0.3s ease;
    transform: rotate(180deg);
    backface-visibility: hidden; /* Forces GPU acceleration */
    perspective: 1000px;        /* Also helps GPU acceleration */
  }

/* Left and right side main panels */

.left-side,
.right-side {
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background-color: var(--panel-background);

    padding: 20px;

    min-width: 0;
    min-height: 0;
}

.left-side h3,
.right-side h3 {
    margin: 0px;
    padding: 0px;
}

.left-side h4,
.right-side h4 {
    margin: 0px;
    padding: 0px;
}

/* Left Side (Grid and Controls) */
.left-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    gap: 10px;
    height: min-content;
    height: 70vh;
}

/* Right Side (Scrollable Content) */
.right-side {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding-left: 20px;
    height: 70vh;
}

.grid-container {
    display: grid;
    gap: var(--grid-cell-gap);
    aspect-ratio: 1 / 1;
    width: 90%;
    max-width: 400px;
    min-width: 200px;
}

.grid-container div {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;

    font-size: var(--grid-cell-font-size);

    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.grid-item {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-family: var(--grid-cell-font-family);
    font-weight: var(--grid-cell-font-weight);
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    position: relative;

    /* Colours for cell that has active contents */
    background-color: var(--grid-cell-tile-background);
    color: var(--grid-cell-tile-color);

    /* Style the letter tile in its normal state with edges and shadows */
    box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);

    /* Add a subtle 3D effect */
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-bottom-color: rgba(0, 0, 0, 0.2);
    border-right-color: rgba(0, 0, 0, 0.2);

    /* Add a slight bevel effect */
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.5),
        inset -2px -2px 5px rgba(0, 0, 0, 0.1);
}

/* The user is currently clicking or dragging through this cell */
.grid-item.selected {
    background-color: var(--grid-cell-selected-background);
    color: var(--grid-cell-selected-color);

    /* Jump when selected */
    transform: scale(1.1);
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
}

/* This cell is empty (e.g. as in a waffle grid)*/
.grid-item.hidden {
    background-color: var(--panel-background);
    cursor: default;
}

/* There are no more scoring words using this letter */
.grid-item.zerozero {
    background-color: var(--grid-cell-completed-background);
    color: var(--grid-cell-completed-zerozero);
}

/* These cells can still be selected */
.grid-item.zerozero.selected {
    background-color: var(--grid-cell-selected-background);
    color: var(--grid-cell-selected-color);
}

/* All key words have been found (i.e. does not include extra words) */
.grid-item.completed {
    background-color: var(--grid-cell-completed-background);
    color: var(--grid-cell-completed-color);
}

/* These cells can still be selected */
.grid-item.completed.selected {
    background-color: var(--grid-cell-selected-background);
    color: var(--grid-cell-selected-color);
}

/* Tweak the appearance in dark mode */
[data-theme="light"] {
    .grid-item.zerozero,
    .grid-item.hidden,
    .grid-item.completed {
        border: none;
    }

    /* Make the hidden cell truly hidden */
    /* .grid-item.hidden {
        box-shadow: none;
    } */
}

/* Tweak the appearance in dark mode */
[data-theme="dark"] {
    .grid-item.zerozero,
    .grid-item.hidden,
    .grid-item.completed {
        box-shadow: none;
    }

    /* Make the hidden cell truly hidden */
    .grid-item.hidden {
        border: none;
    }
}

.grid-item::before,
.grid-item::after {
    position: absolute;
    font-size: 0.4em;
}

.grid-item::before {
    content: attr(word-start-counter);
    font-family: sans-serif;
    left: 2px;
    top: 0px;
    color: var(--word-starts-color);
}

.grid-item::after {
    content: attr(word-contains-counter);
    right: 2px;
    bottom: 0px;
    color: var(--word-contains-color);
}

canvas {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
}

/* Word counts list*/

#word-counts-message {
    padding: 0;
}

.word-count-table {
    width: 100%;
    max-width: 200px;
    border-collapse: collapse;
    margin: 0;
    padding: 0;
}

.word-count-word {
    text-align: left;
    padding: 4px 0 4px 20px;
}

.word-count-total {
    text-align: right;
    padding: 4px 0 4px 0px;
}

/* Ticker tape */

#ticker-container {
    width: 100%;
    /* overflow: hidden; -- reinstate if ticker tape has any problems*/
    background-color: transparent;
    padding: 0px;
}

.particle {
    position: absolute;
    background-color: #ff0000;
    border-radius: 8px;
    pointer-events: none;
}

/* Media queries */

@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        height: fit-content;
    }

    .grid-container {
        max-width: 300px;
    }

    .right-side {
        max-height: 100%;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .game-container {
        flex-direction: column;
    }

    .left-side {
        order: 1;
        min-height: 420px;
    }

    .right-side {
        order: 2;
        overflow-y: unset;
        max-height: none;
    }

    .grid {
        width: 100%;
        max-width: 400px;
    }
}