from common import *
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.rcParams.update({'font.family':'DejaVu Sans','font.size':11,'axes.spines.top':False,'axes.spines.right':False})
fig,ax=plt.subplots(1,2,figsize=(14,5.6),gridspec_kw={'width_ratios':[1,1.5]})
c=pd.read_csv(R/'career_hit_curves.csv');c=c[c.population.eq('all')&c.era.eq('debut2015plus')&c['index'].eq(5)&c.prior.ne('all')].set_index('prior').loc[['low','mid','hit']]
ax[0].bar(['Under 50','50–555','556 or more'],c.r556_rate*100,color=['#98afbe','#638599','#1a607b'],width=.6)
for i,row in enumerate(c.itertuples()):ax[0].text(i,row.r556_rate*100+1.1,f'{row.r556_rate*100:.1f}%\n({row.r556}/{row.n})',ha='center',fontsize=10)
ax[0].set_ylim(0,44);ax[0].set_ylabel('Share reaching 556 reviews (%)');ax[0].set_xlabel("Earlier catalog's largest current review count",labelpad=12)
ax[0].set_title('Prior traction repeats strongly\nOutcome of the fifth observed game',loc='left',fontweight='bold',pad=16)
t=pd.read_csv(R/'tags_and_pairs.csv');names=['Online Co-Op + Roguelite','Local Co-Op + Action Roguelike','Card Game + Base Building','Roguelite + Mystery','Retro + Idler'];labels=['Online co-op + roguelite','Local co-op + action roguelike','Card game + base building','Roguelite + mystery','Retro + idler'];y=np.arange(len(names));width=.34
for rank,offset,color in [(7,-width/2,'#bf754c'),(20,width/2,'#276b83')]:
    a=t[t.period.eq('2023-25')&t['rank'].eq(rank)].set_index('group').loc[names]
    ax[1].barh(y+offset,a.r100_rate*100,height=width,color=color,label=f'Top {rank} tags')
    for j,row in enumerate(a.itertuples()):ax[1].text(row.r100_rate*100+1,j+offset,f'{row.r100}/{row.n}',va='center',fontsize=9)
ax[1].set_yticks(y,labels);ax[1].invert_yaxis();ax[1].set_xlim(0,90);ax[1].set_xlabel('Share reaching 100 reviews (%)');ax[1].legend(loc='lower right',frameon=False)
ax[1].set_title('Several rare niches depend on tag cutoff\nPaid non-explicit releases, 2023–2025',loc='left',fontweight='bold',pad=16)
fig.suptitle('Independent checks of Fable’s Steam findings',x=.055,ha='left',fontsize=17,fontweight='bold')
fig.text(.055,.015,'September 5, 2026 catalog. Current review totals, not equal-age sales. Counts are games; developer credits are not verified personal careers.',fontsize=9,color='#555')
fig.tight_layout(rect=[0,.06,1,.91],w_pad=3)
fig.savefig(R/'verification_overview.png',dpi=170);fig.savefig(R/'verification_overview.svg');plt.close(fig)
