@import url('https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
}

body, html, dialog {
    margin: 0;
    padding: 0;
    background-color: var(--main-bg-color);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--main-text-color);
    font-size: 18px;

    --border-color: #556688;
    --main-text-color: #ddd;
    --secondary-text-color: #8a8;
    --highlight-color: #aaf;
    --box-bg-color: #112233;
    --dark-bg-color: #112;
    --main-bg-color: #0a2a3f;
}

.spoiler {
    user-select: none;
    filter: blur(5px);
    transition: all .2s;
    animation: spoilertext 1s;
}

@keyframes spoilertext {
    0% {
        color: transparent;
    }
    100% {
        color: var(--main-text-color);
    }
}

.revealed {
    animation: reveal 1s;
}

select {
    background-color: var(--box-bg-color);
    color: var(--main-text-color);
    padding: 2px;
}

h3 select {
    padding: 4px;
    font-size: 1em;
}

input[type="range"], input[type="checkbox"] {
    filter: invert(1) hue-rotate(160deg);
}

input {
    font-size: 1rem;
    background-color: var(--box-bg-color);
    color: #fff;
    border: 1px solid var(--border-color);
}

input[type="button"] {
    border: 1px solid var(--border-color);
    background: #0008;
    color: #fff;
    cursor: pointer;
    border-radius: 16px;
    padding: 8px 16px;
    transition: all .2s;
}

input[type="button"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

hr {
    border: none;
    border-bottom: 1px solid var(--border-color);
}

h2 {
    color: var(--highlight-color);
}

h3 {
    color: var(--secondary-text-color);
}

.top-icon:hover, .text-icon:hover, .player-icon:hover, .bubble-icon:hover, .translate-icon:hover, .audio-icon:hover, .choice-icon:hover, .explain-icon:hover {
    transform: translateY(-4px);
    rotate: -5deg;
}

.bubble-icon:hover, .audio-icon:hover, .translate-icon:hover, .speaker:hover {
    transform: scale(1.5);
}

.playing-audio > .text {
    color: #ee8;
    text-shadow: 4px 4px 8px #ff03;
}

@keyframes reveal {
    0% {
        filter: blur(5px);
    }
    100% {
        filter: blur(0px);
    }
}

.text {
    margin: 0; /* remove margin, e.g. for h2 */
}

.bubble {
    position: relative;
    border: 1px solid;
    border-radius: 16px;
    padding: 8px;
    background-color: var(--bubble-bg);
    border: 2px solid var(--character-color);
}

.bubble::after {
    content: ' ';
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid;
    top: calc(40% + 2px);
    bottom: auto;
}

.bubble::before {
    content: ' ';
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid;
    top: 40%;
    bottom: auto;
}

.bubble-right::after {
    left: auto;
    right: -7px;
    border-color: var(--bubble-bg) transparent transparent var(--bubble-bg);
}

.bubble-right::before {
    left: auto;
    right: -12px;
    border-color: var(--character-color) transparent transparent var(--character-color);
}

.bubble-left::after {
    left: -7px;
    right: auto;
    border-color: var(--bubble-bg) var(--bubble-bg) transparent transparent;
}

.bubble-left::before {
    left: -12px;
    right: auto;
    border-color: var(--character-color) var(--character-color) transparent transparent;
}

.speaker {
    background-color: #111;
    border-radius: 50%;
    border: 2px solid var(--character-color);
    margin: 0 8px;
    transition: 0.2s all;
    height: 64px;
    cursor: pointer;
}

.icon {
    /* https://isotropic.co/tool/hex-color-to-css-filter/ */
    filter: invert(76%) sepia(25%) saturate(532%) hue-rotate(202deg) brightness(103%) contrast(101%);
    transition: all .2s;
    cursor: pointer;
}

.translate-icon, .audio-icon {
    height: 1.2rem;
    margin-right: 8px;
}

.bubble-icon {
    height: 2rem;
    display: none;
}

.player-icon {
    height: 2rem;
}

.choice-icon {
    height: 2em;
    vertical-align: middle;
    margin: 8px 8px 8px 0px;
}

.explain-icon {
    height: 2em;
    opacity: 50%;
    margin: 4px;
}

.story-image {
    width: 80%;
    display: block;
    margin: 1em auto;
    border-radius: 16px;
    box-shadow: 2px 4px 10px 0px #000;
    transition: all .2s;
}

.info-box {
    border: 2px solid var(--highlight-color);
    border-radius: 16px;
    padding: 16px 16px;
}

.speech-recognition {
    display: none;
    align-items: center;

    .success {
        font-weight: bold;
        color: var(--highlight-color);
    }

    .listening {
        animation: micPulse 0.5s ease-in-out infinite;
        transform-origin: center;
    }

    .disabled {
        opacity: 0.5;
    }
}

@keyframes micPulse {
    0% {
      transform: scale(1);
      opacity: 1;
    }
    50% {
      transform: scale(1.15);
      opacity: 0.7;
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
}

.small-story-image {
    width: 31%;
    margin: 4px;
    border-radius: 16px;
    border: 1px solid #000;
}

.translation, .legend {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
    margin-block: 0.2em;
}

.badges-strip {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    align-items: center;
}

.badge-pill {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--highlight-color);
    color: var(--highlight-color);
    background: var(--box-bg-color);
}

.story-list {
    .story-info {
        width: 180px;
        position: relative;
        text-align: center;
    }

    .unreleased {
        opacity: 40%;
    }

    .story-count {
        position: absolute;
        top: 0;
        right: 0;
        background: var(--main-bg-color);
        border-radius: 16px;
        border: 2px solid var(--highlight-color);
        padding: 4px;
    }

    .story-complete {
        color: var(--highlight-color);
        font-weight: bold;
    }

    img {
        width: 100%;
        border-radius: 16px;
        border: 2px solid transparent;
    }

    a {
        font-weight: bold;
        text-decoration: none;
    }

    a:hover img {
        border-color: var(--highlight-color);
        scale: 1.1;
        transition: all .2s;
    }

    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.main {
    max-width: 600px;
    margin: 0 auto;
}

summary {
    cursor: pointer;
}

.top {
    background: var(--box-bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 4px;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    padding: 8px;
    transition: all .5s;
    z-index: 10;

    .icon-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        max-width: 600px;
        margin: 0 auto;
    }

    #collection-count, #restart-icon, #settings-icon {
        visibility: hidden;
    }
}

.top-icon {
    width: 36px;
    height: 36px;
    display: inline;
    vertical-align: top;
}

.text-icon {
    font-weight: bold;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    border: 4px solid var(--highlight-color);
    color: var(--highlight-color);
    text-align: center;
    width: fit-content;
    transition: all .2s;
}

.top summary {
    list-style: none;
}

.top details {
    display: inline-block;
}

.footer {
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    height: 140px;
    background: inherit;
    width: 100%;
    padding: 8px;
    align-items: center;
    justify-content: space-evenly;
    display: none;
}

.title {
    h1 {
        color: var(--highlight-color);
        text-transform: capitalize;
        font-variant: small-caps;
        margin-bottom: 4px;
    }

    p {
        font-style: italic;
    }

    border-bottom: 1px var(--highlight-color) solid;
    margin-bottom: 1em;
}

.info {
    border: 1px solid var(--border-color);
    background-color: var(--box-bg-color);
    border-radius: 16px;
    padding: 8px 16px;
    margin: 8px 0;
}

.story-end {
    border: 2px solid #8f8;
    border-radius: 16px;
    padding: 16px 16px;
    margin: 8px 0;
    display: none;

    div {
        flex-wrap: wrap;
        display: flex;
        justify-content: space-around;
    }

    .story-share-actions {
        display: block;
        text-align: center;
        margin-bottom: 4px;
    }

    .story-share-btn {
        cursor: pointer;
        border-radius: 8px;
        background: var(--box-bg-color);
        color: var(--highlight-color);
        font-size: 1em;
    }

    .story-share-btn:hover {
        background: var(--dark-bg-color);
    }

    .story-share-status {
        min-height: 1.25em;
        font-size: 0.85rem;
        color: var(--secondary-text-color);
        margin: 4px 0 0;
    }
}

.certificate {
    width: 64px;
    filter: invert(1);
    float: left;
}

.certificate {
    animation: beat .5s infinite alternate;
}

@keyframes beat{
	to { transform: scale(1.2); }
}

.choices {
    display: grid;
    grid-template-columns: 2em auto;
    row-gap: 4px;
    align-items: center;
    border: 1px solid var(--border-color);
    background-color: var(--dark-bg-color);
    border-radius: 16px;
    padding: 8px;
    margin: 1em 0em;
}

.choice {
    cursor: help;
}

.middle {
    padding: 6px;
    margin-top: 48px;
}

li > label {
    display: inline-block;
    width: 180px;
}

.main-logo {
    height: 1.2em;
    vertical-align: middle;
}

a {
    color: var(--highlight-color);
}

a:hover, summary:hover > * {
    color: var(--main-text-color);
}

#language-selector {
    a {
        font-weight: bold;
        text-decoration: none;
    }

    a:hover img {
        border-color: var(--highlight-color);
        scale: 1.1;
        transition: all .2s;
       }

    ul {
        list-style-type: none;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        padding: 0;
        text-align: center;
        grid-gap: 0.5em;
    }

    li {
        margin: 0;
    }
}

.flag {
    width: 100px;
    vertical-align: middle;
    border-radius: 8px;
    margin: 8px;
    border: 2px solid transparent;
}

p, li {
    margin-block: 0.8em;
    line-height: 1.3em;
    hyphens: auto;
}

.options {
    ul {
        padding-left: 0;
        list-style-type: circle;
    }
}

.top-collection {
    ul {
        padding-left: 0;
        list-style-type: none;
    }
}

.options, .top-collection {
    display: none;
    max-width: 600px;
    margin: 0 auto;

    .small-story-image {
        width: 18%;
        margin: 4px;
        border-radius: 16px;
        border: 1px solid #000;
    }
}

details {
    h2 {
        display: inline-block;
        font-size: 1em;
    }

    ul {
        padding-left: 1em;
        margin-top: 0em;
    }

    li {
        list-style: circle;
    }
}

.sentence-container {
    display: flex;
    position: relative;
    align-items: center;
    margin: 0.75em 0;
    --character-color: #444;
    --bubble-bg: color-mix(in srgb, var(--character-color) 25%, #001);
    position: relative;
    font-size: 1.2rem;

    p {
        margin-block: 0em;
    }

    .word {
        cursor: help;
    }
}

.word-shuffle-game {
    .word {
        display: inline-block;
        padding: 4px;
        margin: 4px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background-color: var(--dark-bg-color);
        cursor: pointer;
        transition: all .2s;
    }

    .greyed-out {
        color: transparent;
        user-select: none;
        background-color: #444;
    }

    .sentence {
        min-height: 2em;
        background-color: #0004;
        border-radius: 8px;
        cursor: pointer;
    }

    .correct-sentence {
        color: #f44;
        font-weight: bold;
        cursor: pointer;
    }
}

.in-story {
    display: none;
}

.story {
    padding-top: 0.35em;
}

.story-page-intro {
    margin-top: 0.35em;
}

.story-credits-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.story-credits-line {
    flex: 1;
    margin: 0;
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    font-style: italic;
    min-height: 1.2em;
}

.story-help-btn {
    flex-shrink: 0;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--highlight-color);
    background: var(--box-bg-color);
    color: var(--highlight-color);
}

.story-help-btn:hover {
    background: var(--dark-bg-color);
}

.story-cover-wrap {
    text-align: center;
    margin-bottom: 4px;
}

.story-cover-img {
    max-width: 100%;
    width: min(280px, 100%);
    height: auto;
    aspect-ratio: 1;
    border-radius: 16px;
    border: 2px solid var(--border-color);
    object-fit: cover;
}

dialog.story-help-dialog.explain-modal {
    max-width: 420px;
}

#back-icon {
    display: none;
}

.home, .in-story {
    display: none;
}

.inventory {
    display: none;
    position: fixed;
    bottom: 106px;
    z-index: 50;
    border: 1px solid var(--border-color);
    background: var(--dark-bg-color);
    max-width: 588px; /* 600px - 2*6px padding in middle */
    width: calc(100% - 12px);
    justify-content: space-around;
    padding: 4px;
    align-items: center;
    border-radius: 16px;
    box-shadow: 2px 4px 10px 0px #000;

    .item {
        width: 48px;
        height: 48px;
        background-size: contain;
        text-align: center;
        color: #000;
        align-items: center;
        display: flex;
        justify-content: center;
        font-weight: bold;
        font-size: 1.4em;
    }

    .updated {
        animation: flip 0.5s;
    }
}

@keyframes flip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

/* Used by edit/syntax UI; story explain modal uses <dialog>::backdrop instead. */
.explain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

dialog.explain-modal {
    border: none;
    padding: 0;
}

dialog.explain-modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.explain-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--main-bg-color);
    padding: 0px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    width: 90%;
    max-height: 90%;
    max-width: 800px;
    overflow-y: auto;
    border-radius: 16px;

    h1 {
        font-size: 1.2em;
        color: var(--secondary-text-color);
    }

    h2 {
        margin: 0px;
    }

    .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px;
        background: var(--box-bg-color);
    }

    .content {
        padding: 16px;
    };

    .close-button {
        background: none;
        border: none;
        color: #fff;
        font-size: 2rem;
        cursor: pointer;
        padding: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background-color 0.2s;
    }

    .close-button:hover {
        background: var(--dark-bg-color);
    }    
}

.updates-cards {
    h2 {
        margin: 8px;
    }

    ul {
        padding: 0;
        margin: 0;
    }

    li {
        background-color: #27374D;
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 0.75rem;
        transition: transform 0.2s ease-in-out;
        list-style: none;
        font-size: 0.9rem;
    }

    li:hover {
        transform: translateY(-2px);
    }

    .date {
        font-size: 0.8rem;
        font-weight: bold;
        color: var(--secondary-text-color);
        margin-right: 8px;
    }

    .news-title {
        font-weight: 700;
        color: #F8FAFC;
    }

    .description {
        margin-top: 0.5rem;
    }
}


button {
    background: var(--main-bg-color);
    color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: .4rem .7rem;
    cursor: pointer;
}

button:hover {
    background: #0056b3;
}

blockquote {
    font-style: italic;
    background-color: var(--box-bg-color);
    padding: 1em;
    line-height: 1.3em;
    hyphens: auto;
}

.social {
    display: flex;
    justify-content: space-evenly;
    margin-bottom: 1.5em;

    .logo, .inv-logo {
        width: 42px;
        height: 42px;
    }

    .logo:hover, .inv-logo:hover {
        border-color: var(--highlight-color);
        scale: 1.3;
        rotate: -5deg;
        transition: all .2s;
    }

    .inv-logo {
        filter: invert(1);
    }
}

/* Styling for the popup itself */
.word-popup {
    position: absolute;
    color: var(--main-text-color);
    font-size: 18px;
    font-weight: normal; /* reset, in case we're inside h2 */

    padding: 1em;
    background-color: #0008;
    backdrop-filter: blur(8px);
    border: 2px solid var(--border-color);

    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow-y: auto;
    border-radius: 16px;
    width: max-content;

    transform: translate(-50%, -100%); 

    .source-word {
        font-weight: bold;
    }

    .translated-word {
        font-style: italic;
        margin: 0 0 8px 0;
    }

    li {
        margin-block: 4px;
    }

    ul {
        margin: 0;
        list-style-type: circle;
        padding-left: 1.5em;
    }
}
