/* The pitch comes in two looks, picked in the editor: a flat top down pitch
   drawn with CSS, and the original artwork drawn in perspective. */
.football-field {
    position: relative;
    width: 820px;
    height: 548px;
    box-sizing: border-box;
}

.football-field.is-flat {
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--squad-field-color, #1f7a3d);
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(255, 255, 255, 0.045) 0 68px,
            rgba(0, 0, 0, 0.045) 68px 136px);
}

.football-field.is-perspective {
    background-color: transparent;
    background-image: url("/images/field-bg.png");
    background-size: contain;
    background-repeat: no-repeat;
}

/* Upright pitch — taller than it is wide, for portrait sized posts. */
.football-field.is-portrait {
    width: 548px;
    height: 820px;
    background-image:
        repeating-linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.045) 0 68px,
            rgba(0, 0, 0, 0.045) 68px 136px);
}

/* Rounded corners leave transparent pixels, which chat apps paint white. */
.football-field.is-capturing {
    border-radius: 0;
}

/* Pitch markings: outer line, halfway line, centre circle and both boxes. */
.football-field.is-flat::before {
    content: "";
    position: absolute;
    inset: 18px;
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 4px;
    pointer-events: none;
}

/* Halfway line and centre spot. */
.football-field.is-flat::after {
    content: "";
    position: absolute;
    inset: 18px;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.75)),
        radial-gradient(circle at center, rgba(255, 255, 255, 0.75) 3px, transparent 3px);
    background-repeat: no-repeat, no-repeat;
    background-position: 0 50%, center;
    background-size: 100% 2px, 100% 100%;
}

.football-field--circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    margin: -75px 0 0 -75px;
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    pointer-events: none;
}

.football-field--box {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 330px;
    height: 92px;
    border: 2px solid rgba(255, 255, 255, 0.75);
    pointer-events: none;
}

.football-field--box.is-top {
    top: 18px;
    border-top: none;
}

.football-field--box.is-bottom {
    bottom: 18px;
    border-bottom: none;
}

.football-field--goal {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 38px;
    border: 2px solid rgba(255, 255, 255, 0.75);
    pointer-events: none;
}

.football-field--goal.is-top {
    top: 18px;
    border-top: none;
}

.football-field--goal.is-bottom {
    bottom: 18px;
    border-bottom: none;
}

/* The upright pitch is narrower and longer, so the boxes follow it. */
.football-field.is-portrait .football-field--box {
    width: 300px;
    height: 112px;
}

.football-field.is-portrait .football-field--goal {
    width: 140px;
    height: 46px;
}

.field-position {
    position: absolute;
    width: 110px;
    height: 124px;
    min-width: 110px;
    min-height: 124px;
    box-sizing: border-box;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    font-size: 0.85rem;
    background-image: url("/images/player.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-color: transparent;
    overflow: visible; /* allow dropdown to expand */
    cursor: grab;
    user-select: none;
}

.field-position:hover {
    filter: drop-shadow(0 0 20px #55cca2);
}

.field-position--player-name {
    color: var(--squad-name-color, gold) !important;
    font-weight: 600;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    display: flex;
    justify-items: center;
    align-items: center;
    justify-content: center;
}

.field-position--player-name div {
    
}

.field-position--player-position {
    position: absolute;
    bottom: 18%;
    width: 100%;
}

/* Avatar mode drops the card artwork and shows the photo with the name below it. */
.field-position.is-avatar {
    background-image: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.field-position--avatar {
    width: 72px;
    height: 72px;
    flex: 0 0 auto;
    border-radius: 50%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border: 3px solid rgba(255, 255, 255, 0.85);
    background-color: rgba(0, 0, 0, 0.35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/* The placeholder is a fixed drawing — show it whole instead of cropping it. */
.field-position--avatar.is-default {
    background-size: contain;
    background-color: #374151;
}

/* A real life photo is drawn straight onto the grass — no frame, no plate,
   no backdrop, so only the face is left standing on the pitch.
   The picture is cut off in a hard line at the shirt, so its own pixels are
   faded out with a mask. Nothing is painted on the pitch, which keeps the
   grass and the markings visible through the fade. */
.field-position--avatar.is-photo {
    position: relative;
    width: 104px;
    height: 104px;
    border: none;
    outline: none;
    border-radius: 0;
    background-color: transparent;
    background-size: cover;
    background-position: center top;
    box-shadow: none;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 96%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 96%);
}

/* The photo carries its own name, sitting right under the picture. */
.field-position.is-photo-slot {
    gap: 0;
    width: 112px;
    height: 140px;
    min-width: 112px;
    min-height: 140px;
    justify-content: flex-start;
}

.field-position.is-photo-slot .field-position--avatar-name {
    margin-top: -6px;
    position: relative;
    z-index: 1;
}

/* Canvas exports ignore mask-image, so during the capture only, the same fade
   is painted in the pitch colour over the photo itself — never wider than the
   picture, so it does not show up as a plate on the grass. */
.football-field.is-flat.is-capturing .field-position--avatar.is-photo::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40%;
    background-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        var(--squad-field-color, #1f7a3d) 88%);
    pointer-events: none;
}


.field-position--avatar-name {
    color: var(--squad-name-color, gold);
    font-weight: 600;
    line-height: 1.1;
    max-width: 100%;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    overflow-wrap: anywhere;
}

.field-position:active {
    cursor: grabbing;
}

.field-position.dragging {
    opacity: 0.4;
    transform: translate(-50%, -50%) !important;
    width: 110px;
    height: 124px;
    min-width: 110px;
    min-height: 124px;
}

.field-position.drop-target {
    filter: drop-shadow(0 0 24px #ffcc00);
}
