* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    width: 100%;
    font-family: sans-serif;
    background-color: #3B4049;
}

.page-enigme {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    overflow-y: auto;
    position: relative;
}

@supports (min-height: 100dvh) {
    .page-enigme {
        min-height: 100dvh;
    }
}

#haut{
  background-color: #2E3540;
  color: white;
  width: 100%;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
  position: sticky;
  top: 0;
  z-index: 10;

  display: grid;
  grid-template-columns: 1fr auto 1fr; 
  align-items: center;
  padding: 12px 16px;
}

#titre {
    flex: 1;
    margin: 0;
    text-align: center;
    color: white;
    font-size: clamp(20px, 4vw, 32px);
    line-height: 1.2;
    padding: 0 40px;
}

.envelope-container {
    flex: 1;
    margin-top: 25px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, auto));
    justify-content: center;
    justify-items: center;
    align-content: space-evenly;
    gap: clamp(16px, 4vw, 40px);
    padding: 0 16px 24px;
    z-index: 20;
}

.wrapper {
    --env-w: min(28vw, 300px);
    --env-h: calc(var(--env-w) * 2 / 3);
    width: var(--env-w);
    height: var(--env-h);
    background-color: #3760C9;
    overflow: visible;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 0;
}

.lid {
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    border-right: calc(var(--env-w) / 2) solid transparent;
    border-bottom: calc(var(--env-h) / 2) solid transparent;
    border-left: calc(var(--env-w) / 2) solid transparent;
    transform-origin: top;
    transition: transform 0.25s linear;
}

.lid.one {
    border-top: calc(var(--env-h) / 2) solid #658ced;
    transform: rotateX(0deg);
    z-index: 3;
    transition-delay: 0.50s;
}

.lid.two {
    border-top: calc(var(--env-h) / 2) solid #3760C9;
    transform: rotateX(90deg);
    z-index: 1;
    transition-delay: 0.25s;
    pointer-events: none;
}

.envelope {
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    border-top: calc(var(--env-h) / 2) solid transparent;
    border-right: calc(var(--env-w) / 2) solid #C4DFF0;
    border-bottom: calc(var(--env-h) / 2) solid #C4DFF0;
    border-left: calc(var(--env-w) / 2) solid #a4d4f2;
    z-index: 3;
}

.letter {
    position: absolute;
    top: 15%;
    bottom: 15%;
    width: 80%;
    height: auto;
    background-color: white;
    border-radius: 15px;
    z-index: 2;
    transition: 0.5s;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.letter p {
    text-align: center;
    font-size: clamp(18px, 4vw, 30px);
    color: #3B4049;
    margin: 0;
}

.wrapper:hover .lid.one {
    transform: rotateX(90deg);
    transition-delay: 0s;
}

.wrapper:hover .lid.two {
    transform: rotateX(180deg);
    transition-delay: 0.25s;
}

.wrapper:hover .letter {
    transform: translateY(-50px);
    transition-delay: 0.5s;
}

a.wrapper {
    text-decoration: none;
    color: inherit;
}

main {
    width: 100%;
    min-height: calc(100vh - 120px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
}

@supports (min-height: 100dvh) {
    main {
        min-height: calc(100dvh - 120px);
    }
}

.blanc {
    color: white;
}

input {
    width: 80%;
    padding: 20px;
    font-size: 28px;
    border: 2px solid #3760C9;
    border-radius: 12px;
    outline: none;
    text-align: center;
    background-color: #f9f9f9;
    box-sizing: border-box;
}

input:focus {
    border-color: #658ced;
    box-shadow: 0 0 8px #658cedaa;
}

#retour {
    margin-right: auto;
    background-color: #658ced;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: clamp(14px, 2.8vw, 18px);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#retour:hover {
    background-color: #4a6cb5;
    transform: translateY(-1px);
}

#special {
    margin: 0 auto;
    background-color: #658ced;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-size: clamp(18px, 4vw, 26px);
}

#special:hover {
    background-color: #4a6cb5;
    transform: translateY(-1px);
}

button#valider {
    padding: 12px 24px;
    font-size: 20px;
    background-color: #3760C9;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button#valider:hover {
    background-color: #2a4ba0;
}

/*.lenver {
    display: inline-block;
    transform: rotate(180deg);
    writing-mode: horizontal-tb;
}*/

.bloc-cartes {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    background-color: rgba(0, 0, 0, 0.25);
    border: 0.1rem solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.35);
    margin-bottom: 1.5rem;
    text-align: left;
}

.bloc-cartes h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.bloc-cartes ul {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}

.bloc-cartes li {
    margin: 0;
}

.code-lettres {
    font-family: monospace;
    font-weight: bold;
    letter-spacing: 0.15em;
}

.hs {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.8;
    font-style: italic;
}

@media (max-width: 768px) {
    #special {
        font-size: 20px;
        padding: 6px 10px;
        white-space: nowrap;
    }
}
