main {  
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    grid-template-rows: 0.5fr 1fr auto;
    gap: 2em;
    grid-auto-flow: row;
    grid-template-areas:
        "Summary Summary Sessions"
        "World Characters Sessions"
        "Party Party Sessions";
    padding: 2em;
}

#campaign-title {
    font-style: italic;
}

section {
    background-color: var(--colour-4);
    border-radius: 1em;
    box-shadow: 0 0 5px black;
    min-height: calc(100% - 2em);
    padding: 1em;
}

.section-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1em;
    width: 100%;
        
    #char-name {
        font-size: 2em;
    }
    
    h3 {
        flex-grow: 1;
    }
}

#Sessions { 
    grid-area: Sessions; 

    display: flex;
    flex-direction: column;
    gap: 1em;

    .session-entry {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: fit-content;
        gap: 1em;
        border: 2px solid var(--colour-1);
        border-radius: 0.75em;

        .session-snippet {
            flex-grow: 1;
            padding: 0.5em;
            display: flex;
            gap: 1em;
        }

        .session-title {
            font-style: italic;            
        }
    }
}

#Summary { grid-area: Summary; }

#World { grid-area: World; }

#Party {
    grid-area: Party;

    display: flex;
    flex-direction: column;
    gap: 1em;

    #party-box, #invites-box {
        display: flex;
        flex-direction: column;
        gap: 0.5em;
    }

    .member-entry, .invite-entry {
        display: flex;
        flex-direction: row;
        align-items: center;
        width: 100%;
        gap: 1em;
        padding: 0.5em;
        border: 2px solid var(--colour-1);
        border-radius: 0.75em;
    }

    .member-character { font-style: italic; min-width: 8em; }
    .member-email     { flex-grow: 1; opacity: 0.75; }

    .invite-character { min-width: 8em; font-style: italic; }

    /* The link is the point of the row, so it takes the room. Read-only rather than
       disabled so it can still be selected by hand where clipboard access is refused. */
    .invite-url {
        flex-grow: 1;
        font-family: monospace;
        font-size: 0.85em;
        padding: 0.25em 0.5em;
    }

    #invite-controls { margin-top: 1em; }
}

#Characters { 
    grid-area: Characters; 

    display: flex;
    flex-direction: column;
    gap: 1em;
    
    #characters-box {
        display: flex;
        flex-direction: column;
        gap: 1em;
    }

    .character-entry {
        display: flex;
        flex-direction: row;
        width: 100%;
        gap: 1em;
        border: 2px solid var(--colour-1);
        border-radius: 0.75em;

        .character-snippet {
            flex-grow: 1;
            padding: 0.5em;
            display: flex;
            gap: 1em;
            
            :first-child {
                flex-grow: 1;
            }

            .character-level, .character-class {
                font-style: italic;
            }
        }

        .session-title {
            font-style: italic;            
        }
    }
}

.char-group {
    width: calc(100%-2em);
    height: min-content;
    
    background: var(--colour-4);
    padding: 1em;
    border-radius: 1em;
    box-shadow: 1px 1px 5px black;
    
    display: flex;
    flex-direction: column;
    gap: 1em;
    
    p {
        font-size: small;
        color: color-mix(in srgb, var(--colour-3) 60%, transparent 40%); 
        align-self: center;
        margin-bottom: -0.5em;
    }
    
    hr {
        color: var(--colour-1); 
    }
}

.char-group-span {
    grid-column-start: 1;
    grid-column-end: 4;
}

label.char-group-span {
    margin-top: 2em;
}

.char-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-auto-rows: auto;
    gap: 1em;
    padding: 1em 1em;
    margin-top: -0.5em;
    overflow-y: scroll;
    
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        black 1em,
        black calc(100% - 1em),
        transparent 100%
    );
    
    div {
        height: 100%;
        display: flex;
        flex-direction: column;
        gap: 1em;
    }
    
    .spell-box {
        border: none;
        
        textarea {
            background: var(--colour-4);
            border: 2px solid var(--colour-1);
            border-radius: 0.5em;
            box-shadow: 1px 1px 5px black;
            margin: 0.5em;
            padding: 0.5em;
            width: calc(100% - 2em);      
        }

    }
}

.check-attrib-list {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    align-content: start;
    margin-bottom: 1em;
    
    label {
        border: none;
        display: grid;
        grid-template-columns: 0.1fr 0.1fr 1fr;
        grid-template-rows: 1fr;
        gap: 0.5em;
        height: 0.1em;

        input {
            width: 3em;
            height: 1em;
        }
        
        input[type="checkbox"] {
            appearance: none;
            background: var(--colour-2);
            border-radius: 0.3em;
            width: 1em;
            box-shadow: inset 1px 1px 3px black;
        }
        
        input[type="checkbox"]:hover {
            background: color-mix(in srgb, var(--colour-1) 50%, transparent 50%);
        }
        
        input[type="checkbox"]:checked {
            background: var(--colour-1);
            box-shadow: 1px 1px 3px black;
        }
    }
}

dialog {
    margin: auto;
    padding: 1em 0;
    max-width: 90%;
    width: fit-content;
    height: 90%;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    
    background: var(--colour-2);
    color: var(--colour-3);
    border-radius: 1em;
    border:none;
    box-shadow: 1px 1px 5px black;
    align-items: center;
    
    .section-title {
        width: calc(100% - 2em);
    }
    
    label {
        display: flex;
        flex-direction: column;
        flex: 1; /* grow, shrink, min-width before wrap */
        padding: 0.5em;
        border: 2px solid var(--colour-1);
        border-radius: 0.5em;
        font-size: small;
        background: var(--colour-4);
        color: color-mix(in srgb, var(--colour-3) 60%, transparent 40%); 
        align-items: center;
        height: min-content;
        
        input {
            text-align: center;
        }
    }
    
    .label-hr {
        --grid-unit-size: 100em;
    }
    
    input, textarea {
        background: none;
        color: var(--colour-3);
        border: none;
        font-size: medium;
        width: 100%;
    }
    
    textarea {
        min-height: 6em;
        resize: none;
    }
    
    textarea.large-text {
        min-height: 12em;
    }
    
    input:focus, textarea:focus {
        outline: none;
    }
    
    .split-input {
        display: grid;
        grid-template-columns:  1fr 0fr 1fr;
        gap: 1em;
        width: 100%;
        align-items: center;
        input {
            text-align: center;
        }
    }
    
    #char-name {
        margin-left: 0.2em;
        font-size: larger;
        margin-right: auto;
    }
    
    select {
        border-radius: 0.5em;
    }
    
    button {
        border-radius: 0.5em;
        max-width: 20em;
    }
    
    .char-game-sys {
        text-wrap: nowrap;
        font-size: small;
    }
}

dialog::backdrop {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.char-actions {
    display: flex;
    gap: 1em;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.danger-button {
    background-color: #860a0a;
}

.danger-button:hover {
    background-color: color-mix(in srgb, #a83232 80%, white 20%);
}

dialog.menu-dialog {
    height: fit-content;
    max-width: min(80%, 26em);
    width: min(80%, 22em);
    padding: 1em 1.5em 1.5em;
    text-align: center;
    gap: 1em;

    .section-title {
        width: 100%;
    }

    .menu-title {
        flex-grow: 1;
        text-align: left;
        font-size: larger;
        margin: 0;
    }

    .menu-view {
        display: flex;
        flex-direction: column;
        gap: 0.5em;
        width: 100%;

        button {
            max-width: none;
            width: 100%;
        }
    }
}

.menu-dialog [hidden] {
    display: none !important;
}

.confirm-message {
    margin: 0 0 1em;
}

/* Dialog open animation */
dialog {
  transform-origin: center;
  animation: dialog-pop-in 0.2s ease-out forwards;
}

@keyframes dialog-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Dialog close animation */
@keyframes dialog-pop-out {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.85) translateY(-15px);
  }
}

/* mobile adaptivity */

@media (max-width: 767px) {
    main {
        display: flex;
        flex-direction: column;
        padding: 1em;
        gap: 1em;
    }

    section {
        min-height: unset;
        width: calc(100vw - 4em);
    }

    .button-link .label{
        display: none;
    }

    #Summary     { order: 1; }
    #Sessions    { order: 2; }
    #Characters  { order: 3; }
    #Party       { order: 4; }
    #World       { order: 5; }
    
    .check-attrib-list {
        gap: none;
        
        label {
            grid-template-columns: 0.1fr 0.05fr 1fr;

            input {
                overflow-x: scroll;
                width: 1.5em;
            }
        }
    }
    
    .char-fields {
        display: flex;
        flex-direction: column;
        width: calc(100% - 2em);

        div {
            height: fit-content;
        }
    }

    label.char-group-span {
        margin-top: 0;
    }
}