/* © Paul Murray 2026 https://github.com/PaulMurrayCbr/Torchbearer */

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

    /* getting rid of annoying artifacts when clicking */
    -webkit-user-select: none;
    user-select: none;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;

}

:root {
    --yellow: #f0a500;
    --disabled-yellow: #8a5f00;
    --gray: #a0a0a0;
    --brighter: #e0e0e0;
    --linkblue: #4040f0;
    --linkvisitedblue: #8040f0;
    --dark: #606060;
    /** brightness goes from 80 to 20 */
    --brightness: 20;

    --torch-width: 1rem;
    --torch-height: 3rem;
    --torch-sizing-width: 2rem;
    --torch-sizing-height: 6rem;
}


html,
body {
    margin: 0;
    padding: 0;
    height: 100%;

    background: rgb(var(--brightness) var(--brightness) var(--brightness));
    transition: background 1s ease;


    /*   transition: background 2s linear; */

    font-family: Arial, Helvetica, sans-serif;
}

#toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0.5rem 1rem;

    height: 3.5rem;
}

#toolbar #title {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#toolbar #title #infobutton {
    color: var(--yellow);
    font-family: monospace;
    font-size: .8rem;

    border-radius: 50%;
    border: thin solid var(--yellow);

    display: inline-flex;
    justify-content: center;
    align-items: center;

    width: 1.2rem;
    height: 1.2rem;
    min-width: 1.2rem;
    min-height: 1.2rem;

    font-weight: bold;
    line-height: 1;
}


#toolbar #buttons {
    display: flex;
    gap: 0.5rem;
}

#toolbar #buttons button {
    color: var(--gray);
    font-size: 1.4rem;
}

#toolbar #buttons button.minutes-pass {
    font-size: 1rem;
}


#time-passes-dropdown {
    width: 9rem;
}

#time-passes-dropdown button {
    font-size: 1rem;
}

button {
    font-size: 1rem;
    margin-bottom: .5rem;

    min-width: 2.5rem;
    min-height: 2.5rem;

    border-radius: 1rem;
    border: thin solid var(--yellow);
    color: var(--yellow);

    background: transparent;
    cursor: pointer;
    text-align: center;
}

button:focus {
    outline: none;
}

button::-moz-focus-inner {
    border: 0;
}

button:active {
    transform: translateY(.125rem);

    transition: transform 200ms linear;

    outline: none;

}

button.on {
    transition: background .25s ease-out;
    background-color: var(--yellow);
    color: var(--gray);
}

button.disabled {
    color: var(--disabled-yellow);
    border-color: var(--disabled-yellow);
    cursor: not-allowed;
}

button.disabled:active {
    /*    transform: none; */
}

#app {
    display: grid;
    grid-template-rows:
        auto    /* toolbar */
        minmax(0, 1fr) /* torch area */
        auto; /* control panel */

    position: absolute;
    inset: 0;
}

#torches {
    position: relative;
    width: 100%;
    height: 100%;
}

#torch-grid-container {
    width: 100%;
    height: 100%;
    display: flex;
    margin-bottom: .5rem;
}

.tgrid {
    margin: 1rem;

    overflow: hidden;

    min-height: 0;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;

}

#torches-grid {
    position: absolute;
    inset: 0;
}

#torches-sizing-grid {
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    pointer-events: none;
}


.torch-container {
    position: relative;
    display: inline-block;

    border: thin solid transparent;
    border-radius: 50%;
    min-height: 0;
    object-fit: fill;
}

#torches-grid > .torch-container {
    width: var(--torch-width);
    height: var(--torch-height);

    transition: width .125s ease-out, height .125s ease-out;
}

#torches-sizing-grid > .torch-container {
    width: var(--torch-sizing-width);
    height: var(--torch-sizing-height);
}


.torch-container.selected {
    border: 2px solid var(--yellow);
}

.torch-container img {
    position: absolute;

    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 0;

    opacity: .5;
    transition: opacity 1s linear;

    user-select: none;
    pointer-events: none;
}

.torch-container .label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    padding: 0.5rem;
    color: var(--gray);
    text-align: center;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

#paused {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    inset: 0;

    z-index: 10;

    background: var(--gray);
    opacity: 0.5;

    pointer-events: auto;
}

#darkness {
    position: absolute;
    inset: 0;

    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 3rem;
    font-weight: bold;
    letter-spacing: 0.2em;

    color: rgba(255, 255, 255, 0.7);

    pointer-events: none;

    opacity: 0;
    transition: opacity 3s ease;

}

#darkness.visible {
    opacity: 1;
}

#toaster {
    position: absolute;
    top: 0;
    left: 0;

    width: 100%;
    height: 50%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    pointer-events: none;
    z-index: 10;

    gap: 0.5rem;
}

.toast {
    color: var(--gray);
    font-size: 1.2rem;
    pointer-events: none;
    text-align: center;
    margin: 0 2rem 0 2rem;

    opacity: 0;
    /*    transform: translateY(1rem); */
    max-height: 0;

    transition: opacity 2s ease,
    max-height 2s ease,
    transform 2s ease;
}

.toast.fadein {
    opacity: 1;
    max-height: 50dvh;
    /*    transform: translateY(0); */
}

.toast.fadeout {
    opacity: 0;
    max-height: 0;
    /*    transform: translateY(-1rem); */
}

#hint-container > * {
    position: absolute;
    top: 0;
    width: 100%;
}

.help {
    font-size: smaller;
    color: var(--gray);
    text-align: center;
    padding-left: 2rem;
    padding-right: 2rem;
}


.dialog {
    background: #0f0f0f;
    border: thin solid var(--yellow);
    border-radius: .5rem;
}

#panel-container {
    height: auto;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: max-height .5s ease-out;
}

#panel-container.open {
    max-height: 50dvh;
}

#panel {
    display: block;
    position: relative;

    overflow: hidden;

    padding: 1rem;
    margin: 1rem;

    color: var(--gray);
}

#panel .title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--yellow);
    margin-bottom: .5rem;
}

#panel #time-remaining {
    font-size: 1rem;
    margin-bottom: .5rem;
}

#panel > button {
    width: 100%;
}

.button-row {
    display: flex;
    gap: 0.5rem;
}

.button-row button {
    flex: 1 1 0;
    min-width: 0;
}

.close-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;

    font-size: 1.5rem;

    min-width: 2rem;
    min-height: 2rem;

    display: flex;
    align-items: center;
    justify-content: center;

}


.hidden {
    display: none;
}

.dropdown {
    position: relative;
}

.dropdown .title {
    color: var(--yellow);
    font-size: 1rem;
}


.dropdown-menu {
    display: none;

    position: absolute;
    right: 0;
    top: 100%;
    width: auto;
    background-color: #0f0f0f;

    border-radius: .5rem;
    cursor: pointer;
    border: thin solid var(--yellow);
    padding: 0.5rem;

    z-index: 10;
}

.dropdown.open .dropdown-menu {
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.dropdown.open .dropdown-menu button {
    display: flex;
    flex-direction: column;
    font-size: 1rem;

    align-items: center;
    justify-content: center;

    width: 100%;
    padding: 0.5rem 1rem;


}

.fader {
    opacity: 1;
    transition: opacity 1s ease;

}

.fader.hidden {
    display: block;
    opacity: 0;
}

#splash-container {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#splash {
    transition: opacity 3s linear;
}

#splash-fade {
    position: fixed;
    inset: 0;

    background-color: #e0e0e0;
    z-index: 999;

    transition: opacity 2s linear;
}


#info-container {
    position: fixed;
    inset: 0;
    z-index: 1000;
    z-index: 998;
    display: none;
}

#info-container.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

#info {
    border: thin solid var(--yellow);
    border-radius: .5rem;
    padding: 1rem;
    background-color: #0f0f0f;
    color: var(--gray);
    max-width: 90%;
    max-height: 0;
    overflow: auto;
    transition: max-height .5s ease;
}

#info.open {
    max-height: 90%;
}


#info strong {
    color: var(--yellow);
}

#info a, #info a {
    color: var(--linkblue);
    text-decoration: underline;
}

#info a, #info a:visited {
    color: var(--linkvisitedblue);
}

#info a:hover {
    color: white;
    text-decoration: underline;
}

#label-container {
    width: 100%;
    display: flex;
    gap: 0;
    border: thin solid var(--yellow);
    border-radius: .5rem;
    margin-bottom: .5rem;

}

#label-title {
    flex: 0 0 auto;
    padding: 0.5rem;
    background-color: transparent;
    color: var(--yellow);
    border-right: thin solid var(--yellow);
}

#label-text {
    flex: 1 1 auto;
    padding: 0.5rem;
    background-color: transparent;
    color: var(--gray);

    cursor: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

